Python string method isdigit() checks whether the string consists of digits only.
Following is the syntax for isdigit() method −
str.isdigit()
NA
This method returns true if all characters in the string are digits and there is at least one character, false otherwise.
The following example shows the usage of isdigit() method.
#!/usr/bin/python str = "123456"; # Only digit in this string print str.isdigit() str = "this is string example....wow!!!"; print str.isdigit()
When we run above program, it produces following result −
True False