isdigit() Function in python – Check for numeric digits only

isdigit() Function in python checks whether the string consists of numeric digits only. lets see an example of python isdigit() Function

Syntax for isdigit() Function in Python:

str.isdigit()

Returns true if numeric digits found else returns false.

Example of isdigit() Function in python:

# test the presence of numeric digits only
str1 = "2018isontheway"; #no space in the string
print str1.isdigit()

str1 = "20156";
print str1.isdigit()

output will be

False
True

 

previous isdigit() Function in python                                                                                                                next isdigit() Function in python