Advertisement
# Signature of isdigit() method
isdigit()
# Python - Method isdigit() Example
# Creating the first string
s1 = ('Scooby dooby doooooo!')
# Printing the first string
print('The first string : ', s1)
# Calling the isdigit() method on first string object
print('isdigit() method on first string : ', s1.isdigit())
# Creating the second string
s2 = ('The 7 chakras')
# Printing the second string
print('The second string : ', s2)
# Calling the isdigit() method on second string object
print('isdigit() method on second string : ', s2.isdigit())
# Creating the third string
s3 = ('4...1..6..1!')
# Printing the third string
print('The third string : ', s3)
# Calling the isdigit() method on third string object
print('isdigit() method on third string : ', s3.isdigit())
# Creating the fourth string
s4 = ('862331')
# Printing the fourth string
print('The fourth string : ', s4)
# Calling the isdigit() method on fourth string object
print('isdigit() method on fourth string : ', s4.isdigit())
The first string : Scooby dooby doooooo!
isdigit() method on first string : False
The second string : The 7 chakras
isdigit() method on second string : False
The third string : 4...1..6..1!
isdigit() method on third string : False
The fourth string : 862331
isdigit() method on fourth string : True
Advertisement
# Python - Method isdigit() Example
# Calling isdigit() method on a string of digits with a comma
print('75,99'.isdigit())
# Calling isdigit() method on a string repesenting a specific currency value
print('8.99$'.isdigit())
# Calling isdigit() method on a string representing a floating value
print('82.99'.isdigit())
# Calling isdigit() method on a string of all digits except a !
print('1000!'.isdigit())
# Calling isdigit() method of all binary digits
print('011101'.isdigit())
False
False
False
False
True
Advertisement
Advertisement
Please check our latest addition
C#, PYTHON and DJANGO
Advertisement