← All snippets

F-String Formatting

Format strings inline with expressions, numbers, and dates — the cleanest way to build strings in Python 3.6+.

tricks

Code

name = "Aarav"
score = 95.5
print(f"{name} scored {score:.1f}%")
# Aarav scored 95.5%