Python string | isdecimal ()

Python Methods and Functions | String Variables

Syntax :

string_name.isdecimal ()
Here string_name is the string whose characters are to be checked

Parameters: This method takes no parameters.

Returns:

True - all characters are decimal
False - one or more then one character is not decimal.

Below is the implementation of the isdecimal () method in Python3:

# Python3 demo program
# isdecimal ()

 

s = "12345"

print (s.isdecimal ())

 
# contains alphabets

s = "12geeks34"

print (s.isdecimal ( ))

 
# contains numbers and spaces

s = "12 34"

print (s.isdecimal ())

Output:

 True False False 




Tutorials