Advertisement



< Prev
Next >



Python - String isdigit() Method



The isdigit() string method returns True if all the characters in a string are digits, otherwise it returns False.

Note : None of the string methods change the original string and only return a new string which reflects the change performed by the string method, hence the returned string must be stored or used(if needed to reflect the result), otherwise it is lost.



Signature of isdigit()


The isdigit() method has no parameters, so we don't have to worry about passing it some value.

# Signature of isdigit() method 
isdigit()





Let us see a few more examples of calling the isdigit() method on all different forms of strings.

# Python - Method isdigit() Example



# Calling isdigit() method on a string of digits with a comma
print('75,99'.isdigit())


# Calling isdigit() method on a string repesenting a specific currency value
print('8.99$'.isdigit())



# Calling isdigit() method on a string representing a floating value
print('82.99'.isdigit())



# Calling isdigit() method on a string of all digits except a !
print('1000!'.isdigit())


# Calling isdigit() method of all binary digits
print('011101'.isdigit())


Output is :


False
False
False
False
True


Program Analysis







Please share this article -





< Prev
Next >
< String isnumeric() Method
String isalpha() Method >



Advertisement

Please Subscribe

Please subscribe to our social media channels for daily updates.


Decodejava Facebook Page  DecodeJava Twitter Page Decodejava Google+ Page




Advertisement



Notifications



Please check our latest addition

C#, PYTHON and DJANGO


Advertisement