Python Forum
Question: print issue - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Question: print issue (/thread-38219.html)



Question: print issue - python202209 - Sep-17-2022

Ask a silly question:

Why I got SyntaxError for print(1,012,000) but not print(1,000,000)?

See attached screenshot.


RE: Question: print issue - snippsat - Sep-17-2022

If you had used Python 3.10 then would have gotten Better error messages
So it i run it on Python 3.10.5,no need to search for an answer as the hint is in error message.
>>> print(1,012,000)
  File "<interactive input>", line 1
    print(1,012,000)
            ^
SyntaxError: leading zeros in decimal integer literals are not permitted; use an 0o prefix for octal integers

>>> print(1,0o12,000)
1 10 0
>>> 
>>> print(1,000,000)
1 0 0



RE: Question: print issue - deanhystad - Sep-17-2022

Interesting that 000 does not have leading zeros.


RE: Question: print issue - jefsummers - Sep-18-2022

Wild guess here, but I bet you wanted it to print 1,012,000. As in a million twelve thousand. In that case, you need to ditch the commas.