The isdigit() method in Python String checks whether the string consists of digits only. In Python strings, isdigit() method is again inbuilt and is utilized for handling strings. The isdigit() method in Python is supposed to return True when all characters found in the string are digits, else, It would return False.
Here is the syntax for isdigit() method:
str.isdigit()
This method returns true when all characters are digits in the string and there lies at least one character, otherwise, it returns false.
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 the above program, it produces the following result
True False
Here at Intellinuts, we have created a complete Python tutorial for Beginners to get started in Python.