f-string (Python)

An f-string is Python's way of inserting variables directly inside text. You prefix the string with f and put expressions inside curly braces.

Python

Syntax

f"text {expression} more text"

Examples

Python

name = "Sam"
age = 20
print(f"{name} is {age}")

Output:

Sam is 20

Learn it in a lesson

See also

Back to the Dictionary