Mar-23-2023, 10:47 AM
XY-Problem?
Do you want to compare serial numbers or postal codes?
e.G. in Germany, we have postal-codes with 5 digits and some of them with a leading zero.
Is equal:
The opposite is, if you have converted e.G. a postal-code to int and you print it, you get a different postal-code:
Do you want to compare serial numbers or postal codes?
e.G. in Germany, we have postal-codes with 5 digits and some of them with a leading zero.
Is equal:
int("01234") == int("1234")Is not equal:
"01234" == "1234"It's better not to convert a
str
to int
, if the leading zero has a meaning.The opposite is, if you have converted e.G. a postal-code to int and you print it, you get a different postal-code:
print(int("042"))
Almost dead, but too lazy to die: https://sourceserver.info
All humans together. We don't need politicians!
All humans together. We don't need politicians!