0

In String formating using %, What does here 5 means in 5.2f ?

I tried many examples with different number there in place of 5 but I didn't noticed any change.

19th Sep 2021, 3:49 AM
I Am a Baked Potato
I Am a Baked Potato - avatar
4 Answers
+ 3
It's the width. https://python-reference.readthedocs.io/en/latest/docs/str/formatting.html Notice that this is an older style of formatting and is no longer recommended. Read more about it here: https://realpython.com/python-string-formatting/
19th Sep 2021, 4:38 AM
Simon Sauter
Simon Sauter - avatar
+ 2
Simon Sauter Thank you! Actually I'm trying to understand different way of formatting strings. I normally use str.format() or f-string
19th Sep 2021, 4:46 AM
I Am a Baked Potato
I Am a Baked Potato - avatar
+ 1
Tushar Kumar 🇼🇳 Can you give a working demonstration.
19th Sep 2021, 4:30 AM
Rik Wittkopp
Rik Wittkopp - avatar
19th Sep 2021, 4:36 AM
I Am a Baked Potato
I Am a Baked Potato - avatar