Python String isdecimal() Method
The isdecimal() method is a string method that returns True if all the characters in the string are decimal characters (0-9).
For example:
num = "123"
print(num.isdecimal())
# prints True
The method returns False if the string contains any non-decimal characters, such as letters, spaces, punctuation marks, symbols, etc.
For example:
num = "12.3"
print(num.isdecimal())
# prints False
If you have any questions about this code, you can drop a line in comment.
Comments
Post a Comment