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