THE WORLD'S LARGEST WEB DEVELOPER SITE

Python String isnumeric() Method

❮ String Methods


Example

Check if all the characters in the text are numeric:

txt = "565543"

x = txt.isnumeric()

print(x)
Run example »

Definition and Usage

The isumeric() method returns True if all the characters are numeric (0-9), otherwise False.

Exponents, like ² and ¾ are also considered to be numeric values.


Syntax

string.isnumeric()

Parameter Values

No parameters.


More Examples

Example

Check if the characters are numeric:

a = "\u0030" #unicode for 0
b = "\u00B2" #unicode for ²
c = "10km2"

print(a.isnumeric())
print(b.isnumeric())
print(c.isnumeric())
Run example »

❮ String Methods