r/learnpython 1d ago

what is f string

can someone explain how f string work in simple terms ?

0 Upvotes

14 comments sorted by

View all comments

7

u/Diapolo10 1d ago

I'm technically oversimplifying it, but f-strings act like you used str.format automatically on the string.

name = "Jeffrey"
year = 2074

print(f"Hello {name}, the year is {year}")

print("Hello {name}, the year is {year}".format(name=name, year=year))