Isdigit() Method Of Str Class

Method Name:

isdigit

 

Method Signature:

isdigit()

 

Method Overview:

  • The isdigit() method returns True if the string object is solely made of digits.

 

  • If any character of the string is a non-digit, or if the string is an empty string, isdigit() will return False.

 

Example:

# Check a float

piVal       = "3.14"

digitStatus = piVal.isdigit()

print(digitStatus)

 

# Check an alphanumeric string

testString  = "Formula1"

digitStatus = testString.isdigit()

print(digitStatus)

 

# Check this is all digits

emirp       = "73"

digitStatus = emirp.isdigit()

print(digitStatus)

 

Output:

False

False

True


Copyright 2023 © pythontic.com