The method isdigit() returns True if all the characters are digits. It returns False if not.
The syntax of the method is: str.isdigit()
Key Points :
• There are no isdecimal() function parameters.
• In Python, the digit characters are often known to be superscript and subscribers (usually encoded with Unicode). So if these characters are found in the string along with decimal characters, isdigit() returns True.
• Roman numerals, currency numerators, and fractions (usually written with Unicode) are called numeric but not digit characters. If the string includes these characters, isdigit() returns False.
Return Value from isdigit()
The isdigit() returns:
• True if all string characters are digits.
• False or not a digit is at least one letter.
Below is the python program to demonstrate the isdigit() function:
str = "123456"; # Only digit in this string print (str.isdigit()) str = "The Best Learning Resource for Online Education"; print (str.isdigit())
When we run above the program, the outcome is as follows:
True
False
Below are several other functions that we can use to work with string in Python 3