[Tutor] Why does 01 give a syntax error, but 00 (or 00...0) does not?
boB Stepp
robertvstepp at gmail.com
Sat Mar 5 18:20:21 EST 2016
>>> 01
File "<stdin>", line 1
01
^
SyntaxError: invalid token
>>> 00
0
>>> -00
0
>>> 000
0
Why do zeros not give a syntax error, but other numbers with a leading
zero do give a syntax error? An online search reveals that in Python
2 a leading 0 starts an octal number, but this was changed in Python
3. But then why is 00...0 valid, that is, does not give a syntax
error?
TIA!
--
boB
More information about the Tutor
mailing list