Strings & text
Easy
F-string formatting
Embed variables and expressions inside readable f-strings.
How it works
F-strings (formatted string literals) are the preferred way to build text in modern Python.
Put an f before the opening quote, then wrap values in curly braces. You can call methods and use format specifiers like :.2f for two decimal places.
They are faster to read than concatenation and safer than old %-style formatting.
name = "Ada"
score = 97.5
label = f"{name} scored {score:.1f}%"
print(label)
print(f"Next year: {2026 + 1}")
Sponsored
Sponsored
Reserved space — layout preview until AdSense is connected