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

Python String isdigit() Method

Python String isdigit() Method

Python String isdigit() Method returns true if all the characters in the string consist of digits only and there is atleast one character and returns False if no character is digit in the string.

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

isDigit= "90510"
x = isDigit.isdigit()
print(x)

Output:
true
Example 2:

str1 = "546!@#$"  
if str1.isdigit() == True:  
    print("String is digit")  
else:  
    print("String is not digit")  

Output:
String is not digit

No Sidebar ads