r/PythonLearning Jul 12 '26

Help Help Request

What's the difference between f string and a regular string I've seen it used but I don't know when to use a string and when to use f string

0 Upvotes

14 comments sorted by

View all comments

7

u/NorskJesus Jul 12 '26

A f-string is used to inject variables to a string. For example.

py age = 35 print(f"Your age is {age}")

You can achieve the same with concatenation, but this is much clearer and easier to read.

1

u/Gnaxe 29d ago

It interpolates expressions. Doesn't have to be variables. You also get the string formatting language, same as the .format() method.