Python - String Method - isdecimal() Tutorial
The isdecimal() method returns True if all characters in the string are decimal. otherwise, it returns False.
Syntax-
String.isdecimal()
Example-
#contain white space and alphabet
str1 = "Hello Sam425"
print(str1.isdecimal())
#contain only decimal
str2 = "425"
print(str2.isdecimal())
str3 = "\u0030" #unicode for 0
print(str3.isdecimal())
str4 = "\u00B2" #unicode for square -2
print(str4.isdecimal())
Output-
False
True
True
False