Thursday, March 8, 2018

String isdigit() Method


String isdigit() Method in Python 3


The method isdigit() checks whether the string consists of digits only.
Syntax
str.isdigit()

Return Value
This method returns true if all characters in the string are digits and there is at least one character, false otherwise.
Example
#!/usr/bin/python3
str = "123456"; # Only digit in this string
print (str.isdigit())
str = "this is string example....wow!!!"
print (str.isdigit())

Result
True
False