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