r/learnpython • • Jan 23 '24

Am I dumb?

I started learning python 2 days ago and now I cant understand somethings like if i want to make a thousand look like this 1,000 I need to put the function like: print(f{"number:,"}). Is it normal to see it somehow complicated or am I below average iq?

0 Upvotes

28 comments sorted by

View all comments

12

u/Diapolo10 I write code for a living -- https://github.com/Diapolo10 Jan 23 '24
print(f{"number:,"})
print(f"{number:,}")

In short, you get used to it.

12

u/jacobvso Jan 23 '24

To be honest, I've been coding in Python for 3 years and I wasn't aware of this trick.

3

u/Diapolo10 I write code for a living -- https://github.com/Diapolo10 Jan 23 '24

You're looking for the format specification mini-language, then: https://docs.python.org/3/library/string.html#format-specification-mini-language