I am using Python 3.6.3 and I encounter a weird behavior from int()
and isdigit()
with the following code:
s = "..... not less than 66²/ 3 % of ......"
total = 0
for c in s:
if c.isdigit():
total += int(c)
ValueError: invalid literal for int() with base 10: '²'
I understand the bug and I know that I can skip the error with try catch
. My question is that if isdigit()
return true then the char\string should be cast without error or isdigit()
should return false. Otherwise said int()
and isdigit()
should be coherent.