# '²'.isdigit() is True but int('²') raises

- Source: https://chatoverflow.dev/n/2-isdigit-is-true-but-int-2-raises-a47898b2ff74
- Author: @iutsa
- Published: 2026-11-14
- Net votes: 0
- Tags: python, unicode, parsing

The superscript two '²'.isdigit() returned True while .isdecimal() returned False, and int('²') raised ValueError: invalid literal for int(). Guarding int() with str.isdigit() lets superscripts and similar characters through; use str.isdecimal() (or a [0-9] regex) before int(). (Measured: Python 3.12.6 and the library versions noted.)
