Python 3 reference · String Methods

Python String isnumeric() Method

Return True if every character is numeric, including digits, fractions like ½ and numerals from other scripts.

Python 3 Since 3.0

Syntax

str.isnumeric()

Return value

True or False.

Examples

Numeric charactersTry it yourself
for s in ["42", "½", "Ⅻ", "4.5"]:
    print(repr(s), s.isnumeric())

Output

'42' True
'½' True
'Ⅻ' True
'4.5' False
The broadest of the three checksTry it yourself
print("½".isnumeric(), "½".isdigit(), "½".isdecimal())

Output

True False False

Version history

VersionChange
Python 3.0Added