DEV Community

[Comment from a deleted post]
Collapse
 
juancarlospaco profile image
Juan Carlos

You missing the underscores on numbers like 1_000.
Good post.

Collapse
 
sharmapacific profile image
Prashant Sharma

@juan Thanks for letting know, This is kind of a fun new feature in Python 3.6 -
In this basically we can write long numbers with underscore where the comma normally would be -

>>> 9_89_1212
9891212
>>> '{:_}'.format(9891245)
'9_891_245'
>>> '{:_}'.format(987654321)
'987_654_321'

The number with the underscore behave the same as a normal number do during calculation-

>>> 987_654_321 - 9_891_245
977763076
>>> 
>>> 987_654_321 + 9_891_245
997545566