Skip to main content

isdecimal()

The isdecimal() method is a Python string method that returns True if all the characters in a string are decimal characters, such as numbers from 0-9, and there is at least one character in the string, otherwise it returns False.

Parameter Values

This function does not accept any parameters.

Return Values

The isdecimal() method returns a boolean value: True or False.

How to Use isdecimal() in Python

Example 1:

The isdecimal() method returns True if all characters in a string are decimal characters (0-9).

text = '12345'
print(text.isdecimal()) # Output: True
Example 2:

The isdecimal() method returns False if the string contains any non-decimal characters.

text = '123abc'
print(text.isdecimal()) # Output: False
Example 3:

The isdecimal() method does not consider any other types of digits, such as superscript or subscript digits, as decimal digits.

text = '⁰¹²³'
print(text.isdecimal()) # Output: False