If all the characters in the string are decimal, the Python isdecimal() method returns True. Decimal characters are the characters of base 10. If not, False returns.
The syntax of the method is: str.isdecimal()
Key Points :
• There are no isdecimal() function parameters.
• If all characters in a string are decimal characters, the isdecimal() method returns the True. If not, False returns.
•The superscript and subscripts are considered digit characters but not decimals. If these characters are found in the string (usually written using Unicode), isdecimal() returns False.
• Additionally, roman numerals, currency numerators, and fractions (generally written with Unicode) are called numerical numbers but not decimals. In this case, the isdecimal() still returns False.
Return Value from isdecimal()
The isdecimal() returns:
• True if all string characters are decimal.
• False if not a decimal character at least one.
Below is the python program to demonstrate the isdecimal() function:
str = u"Lucky786"; print (str.isdecimal()) str = u"786"; print (str.isdecimal())
When we run above the program, the outcome is as follows:
False
True
Below are several other functions that we can use to work with string in Python 3