In the Python interpreter, 08
and 09
seem invalid. Example:
>>> 01
1
>>> 02
2
>>> 03
3
>>> 04
4
>>> 05
5
>>> 06
6
>>> 07
7
>>> 08
File "<stdin>", line 1
08
^
SyntaxError: invalid token
>>> 09
File "<stdin>", line 1
09
^
SyntaxError: invalid token
As you can see, only 08
and 09
don't seem to work. Are these special values or something?
A number with a leading zero is interpreted as octal literal. So 8 and 9 are invalid in octal. Only digits 0 to 7 are valid.
Try in interpreter:
>>> 011
9
>>> 012
10
>>> 013
11
If a number starts with 0, it means it's an octal number:
>>> 010
8
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With