r/PythonLearning • • Jul 12 '26

Help Request Help

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

3

u/[deleted] Jul 12 '26

[removed] — view removed comment

2

u/Outside_Complaint755 Jul 12 '26 edited Jul 13 '26

Also, if you include an = in the {}, it will include the expression in the output and maintain whitespace.  Example:

a = 2
b = 6
print(f"Demonstration: {float(a + b) = }!")

will output

Demonstration: float(a + b) = 8.0!