← Go Back

How to Insert Variables Into Strings

Putting the variables inside a pair of curly braces and adding an "f" before the first quote. For example:

name = "John"
age = 30
print(f"Your name is {name} and you are {age} years old.")

This prints:

Your name is John and you are 30 years old.

strings objects

🐍 You might also find interesting: