Error in python | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Error in python

I think I found and error in the Python language. It fails to parse leading zeros in integers. Print(0123) will caused the error. Mathematically 0123 is still 123, I know that's unusual but it still valid. https://code.sololearn.com/c9enYpb17tjz/?ref=app

19th Sep 2018, 6:10 PM
Rick Shiffman
Rick Shiffman - avatar
3 Answers
+ 4
perl prints 83 for print(0123), it thinks 0123 is octal not an error
19th Sep 2018, 6:19 PM
Rick Shiffman
Rick Shiffman - avatar
+ 4
good question and thanks for the information 💗🙌
19th Sep 2018, 7:13 PM
NimWing Yuan
NimWing Yuan - avatar
+ 3
Python's expecting an integer literal specifier: https://docs.python.org/3/reference/lexical_analysis.html#integer-literals 0xFF 0b010010 In Python 3, octal literals require an "o": 0o1234 Specifically with respect to integers starting with 0, I understand this syntax error and the "0o..." disambiguation of octal literals (from C-style octals, as used in Python 2) to be intentional. * edit: It took me a while to find the right docs, Googling for "integer literals" is noisy.
19th Sep 2018, 6:37 PM
Kirk Schafer
Kirk Schafer - avatar