Home >>Python String Methods >Python String isnumeric() Method

Python String isnumeric() Method

Python String isnumeric() Method

Python String isnumeric() Method in python returns true if all the characters of the string are numeric (0-9), otherwise returns false. It includes Unicode numeric value property.

Syntax:
string.isnumeric()
Here is an Example of Python String isnumeric() Method:

Isnum = "1276583"
x = Isnum.isnumeric()
print(x)

Output:
True
Example 2:

str1 = "12345678"  
if str1.isnumeric() == True:  
    print("Numeric")  
else:  
    print("Not numeric")  
str2 = "123-456-78"
if str2.isnumeric() == True:  
    print("Numeric")  
else:  
    print("Not numeric")  

Output:
Numeric
Not numeric

No Sidebar ads