Sep-17-2022, 06:45 PM
Ask a silly question:
Why I got SyntaxError for print(1,012,000) but not print(1,000,000)?
See attached screenshot.
Why I got SyntaxError for print(1,012,000) but not print(1,000,000)?
See attached screenshot.
Question: print issue
|
Sep-17-2022, 06:45 PM
Ask a silly question:
Why I got SyntaxError for print(1,012,000) but not print(1,000,000)? See attached screenshot.
Sep-17-2022, 07:24 PM
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
Sep-17-2022, 10:44 PM
Interesting that 000 does not have leading zeros.
Sep-18-2022, 11:51 AM
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.
|
|
Possibly Related Threads… | |||||
Thread | Author | Replies | Views | Last Post | |
question about input, while loop, then print | jamie_01 | 5 | 2,688 |
Sep-30-2021, 12:46 PM Last Post: Underscore |
|
question about python3 print function | jamie_01 | 5 | 2,667 |
May-25-2020, 09:58 AM Last Post: pyzyx3qwerty |
|
python 2D array creation and print issue | developerbrain | 5 | 2,828 |
May-15-2019, 01:38 PM Last Post: developerbrain |
|
question on PRINT | PEIXI | 4 | 3,476 |
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 |