Skip to content

Python print(f-string)

  • by

To print Python print(f-string), you need to enclose each of the variable names inside a set of curly braces.

f"This is an f-string {var_name} and {var_name}."

Python print(f-string)

Simple example code Print Variables using Python f-Strings. Just specify the names of the variables inside a set of curly braces {}. And all variable names will be replaced with their respective values.

name = "John"
age = 32
print(f"I'm  {name} age {age}.")


Python print(f-string)

Do comment if you have any doubts or suggestions on this Python string formatting topic.

Note: IDE: PyCharm 2021.3.3 (Community Edition)

Windows 10

Python 3.10.1

All Python Examples are in Python 3, so Maybe its different from python 2 or upgraded versions.

Leave a Reply

Your email address will not be published. Required fields are marked *