Python isdigit() Function checks given string all the characters are digits or not. This method returns True
if all characters in a string are digits. If not, it returns False
.
string.isdigit()
Python isdigit() Function Example
Simple example code check if all the characters in the text are digits.
str1 = '123'
print(str1.isdigit())
str2 = 'Python'
print(str2.isdigit())
s1 = '\u00B23455'
print(s1.isdigit())
s2 = '\u00BD'
print(s2.isdigit())
Output:
Use the isnumeric() method to check whether a character is a numeric character or not.
Do comment if you have any doubts or suggestions on this Python function code.
Note: IDE: PyCharm 2021.3.3 (Community Edition)
Windows 10
Python 3.10.1
All Python Examples are in Python 3, so Maybe its different from python 2 or upgraded versions.