Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Question: print issue
#1
Ask a silly question:

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

See attached screenshot.

Attached Files

Thumbnail(s)
   
Reply
#2
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
Reply
#3
Interesting that 000 does not have leading zeros.
Reply
#4
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.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Exclamation question about input, while loop, then print jamie_01 5 2,686 Sep-30-2021, 12:46 PM
Last Post: Underscore
  question about python3 print function jamie_01 5 2,664 May-25-2020, 09:58 AM
Last Post: pyzyx3qwerty
  python 2D array creation and print issue developerbrain 5 2,821 May-15-2019, 01:38 PM
Last Post: developerbrain
  question on PRINT PEIXI 4 3,474 Oct-13-2018, 06:46 PM
Last Post: PEIXI
  Issue using print statement in a thread bweiss1258 9 5,408 Jan-16-2018, 02:07 AM
Last Post: bweiss1258
  Question on `print f.read()` behavior pythonjohn 2 4,440 Nov-07-2016, 10:18 PM
Last Post: pythonjohn

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020