Python String isnumeric() Method

Example

Check if all characters in the text are numbers:

txt = "565543"
x = txt.isnumeric()
print(x)

Run Instance

Definition and Usage

If all characters are numbers (0-9), the isnumeric() method returns True, otherwise it returns False.

Exponents (such as ² and ¾) are also considered numeric values.

Syntax

string.isnumeric()

Parameter value

No parameters.

More Examples

Example

Check if the character is numeric:

a = "\u0030" #unicode for 0
b = "\u00B2" #unicode for ²
c = "10km2"
print(a.isnumeric())
print(b.isnumeric())
print(c.isnumeric())

Run Instance