← All lessons

f-strings

Sign in · Sign up

Lesson 1.5

An f-string puts values right into the text. Put f before the quotes and names in curly braces:

name = "Mia"
print(f"Hello, {name}!")   # Hello, Mia!

Build a business card in three lines — name, age and city:

Name: Mia
Age: 14
City: London
Hint

In an f-string there is f before the quote and values go in curly braces: f"{x}".

Three variables and three print calls with the text Name:, Age: and City: — just like in the task.