Skip to content
loading...

re: Python Underscores Explained VIEW POST

TOP OF THREAD FULL DISCUSSION
re: You missing the underscores on numbers like 1_000. Good post.
 

@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
code of conduct - report abuse