Advertisement



< Prev
Next >



Python - String isdecimal() Method



The isdecimal() string method returns True if all the characters in a string are decimal numbers i.e. from 0 to 9, 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 isdecimal()


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

# Signature of isdecimal() method 
isdecimal()





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

# Python - Method isdecimal() Example



# Calling isdecimal() method on a string of decimal values with a comma
print('75,99'.isdecimal())


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



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



# Calling isdecimal() method on a string of all decimal values except a !
print('1000!'.isdecimal())


# Calling isdecimal() method of all decimal values
print('011101'.isdecimal())


Output is :


False
False
False
False
True


Program Analysis







Please share this article -





< Prev
Next >
< String isalnum() Method
String isidentifier() 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

PYTHON


Advertisement