Python string | isdecimal()

isdecimal()-It is a function in Python that returns true if all characters in a string are decimal. If all characters are not decimal then it returns false.

Syntax:

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



Parameters:This method does not takes any parameters .

Returns Value:

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

Below is the Python3 implementation of isdecimal() method:

filter_none

edit
close

play_arrow

link
brightness_4
code

# Python3 program to demonstrate the use
# of isdecimal() 
  
s = "12345"
print(s.isdecimal())
  
# contains alphabets
s = "12geeks34"
print(s.isdecimal())
  
# contains numbers and spaces
s = "12 34"
print(s.isdecimal())

chevron_right


Output:

True
False
False


My Personal Notes arrow_drop_up

Striver(underscore)79 at Codechef and codeforces D

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




Article Tags :

1


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.