The question of why the error occurred was answered by others; There was a convention for numeric literals in Python, so literals starting with 0 were considered octal. If you put a digit greater than 7 in such a literal, the result was an error. Then, with Python 3, this convention was changed, and all literals with 0 at the beginning caused an error.
Second question: why does int not throw this error. int does not throw this error because it has its own convention for specifying the base of the string: an optional second argument with a default value of 10. This allows int to accept a wider range of values without any problems for ambiguity. Consider this, for example:
>>> int('55', 16) 85 >>> int('0x55', 16) 85
The base is indicated here; there is no ambiguity. In this case, it would be an obstacle to reject strings with the usual 0x at the beginning. Likewise, it would be unreasonable to reject lines with 0 at the beginning, when the base is uniquely 10.
In general, for me it makes sense (for me) that the language be strict with literals, but more flexible with type conversions.
source share