With Python 3.8, is there a reason why 00 or 000000 are valid while 03 yields an error?
>>> 000
0
03
File "<stdin>", line 1
03
^
SyntaxError: leading zeros in decimal integer literals are not permitted; use an 0o prefix for octal integers
Yes. Python's constants derived from C, where integers starting with a 0 are interpreted in octal. So, 0377 has the decimal value 255. Over time, Python was changed to the 0o prefix, but C still allows the 0 prefix. To avoid any potential confusion, the 0 prefix is now a syntax error.
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