String Methods
isnumeric()
Check whether every character has a numeric value.
str.isnumeric()
Check whether every character has a numeric value.
Returns
True when the string is non-empty and all characters are numeric; otherwise False.
Try it
Run it and change it
text = "½" print(text.isnumeric())
Worth knowing
isnumeric()is the broadest of the three common number checks. It accepts characters such as fractions thatisdigit()andisdecimal()may reject.