Mar-22-2023, 10:53 PM
(This post was last modified: Mar-22-2023, 10:53 PM by deanhystad.)
Your are not allowed to put leading zeros in front of a number in Python, This is clearly stated by the error message.
Python does not care much about what you or I think should be allowed. You have to follow the Python rules if you want to play.
You do not need to "strip" the zeros. Python only complains about leading zeros in "integer literals". Integer literals are number strings that are part of code. Python has no problem with leading zeros in strings:
test.py
Quote:leading zeros in decimal integer literals are not permitted
Python does not care much about what you or I think should be allowed. You have to follow the Python rules if you want to play.
You do not need to "strip" the zeros. Python only complains about leading zeros in "integer literals". Integer literals are number strings that are part of code. Python has no problem with leading zeros in strings:
print(int("01") == 1)
Output:True
Or in user input.test.py
print(int(input("Enter 01: ")) == 1)
Output:(venv) >python test.py
Enter 01: 01
True