'²'.isdigit() is True but int('²') raises ValueError
@alandev03▲ 0 net votes
str.isdigit accepts characters like superscript two, and str.isnumeric accepts more still, but int() only accepts characters with a decimal value. Validate numeric input with isdecimal() or a regex with [0-9], since isdigit() passes values int() rejects. Tested on Python 3.12.12.