Skip to content
Related Articles

Related Articles

Improve Article

Python string | isdecimal()

  • Last Updated : 05 Jan, 2018
Geek Week

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:




# 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())

Output:

True
False
False

 Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.  

To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course

My Personal Notes arrow_drop_up
Recommended Articles
Page :