Why a number like 01 gives a Syntax error in python interactive mode
python, python-3.x, syntax-error
Solution
Historically, integer literals starting with zero denoted octal numbers. This has been abolished in Python 3, and replaced with a different syntax (`0o...`).
The old syntax is no longer accepted, except when the number consists entirely of zeros:
Python 3.3.0 (default, Dec 1 2012, 19:05:43)
>>> 0
0
>>> 00
0
>>> 01
File "<stdin>", line 1
01
^
SyntaxError: invalid token
Problem
Why a number like `01` gives a Syntax error when `01` is typed in python interactive mode and pressed enter? When `00` is entered the interpreter evaluates to `0`, however numbers like `01`, `001` or anything which starts with a `0` is entered Syntax error:invalid token is displayed. Entering `1,000` in prompt evaluates to a tuple of `(1,0)` but `1,001` doesn't evaluate to `(1,1)` instead Syntax error is displayed. Why does the Python interpreter behave so?