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:
# Python3 program to demonstrate the use# of isdecimal() s = "12345"print(s.isdecimal()) # contains alphabetss = "12geeks34"print(s.isdecimal()) # contains numbers and spacess = "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


