Python String isdigit() Method

Returns True if all characters in the string are digits. This includes superscript / subscript digits and digits in other languages.

Syntax

Python
string.isdigit()

Example

Python
str1 = '0123456789' # Decimals
str2 = '??????????'    # Tibetan decimals 0-9
str3 = '<sup>038</sup>'         # superscript digits
str4 = '?'          # the fraction character 1/8th
str5 = '0A'         # A string with an alphabetic character
print(str1.isdigit())
print(str2.isdigit())
print(str3.isdigit())
print(str4.isdigit())
print(str5.isdigit())

Output

True
True
True
False
False