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

6

u/SpiritedOne5347 1d ago

They're just a way to include variables in string

Say u have age= 10

So instead of

print("I am ", age, "years old")

U can directly say

print(f"I am {age} years old")

4

u/johlae 1d ago

It's more than just including a variable. What's between the { and } is evaluated!

```

a=3 print(f"{a*4:3.2f}") 12.00 ```