Advertisement



< Prev
Next >



Python - String isalnum() Method



The isalnum() string method returns True only if all the characters in the invoked string are - In all other cases, the isalnum(), returns False.

Note : None of the string methods change the original string and only return a new string which reflects the change performed by the string method, hence the returned string must be stored or used(if needed to reflect the result), otherwise it is lost.



Signature of isalnum()


The isalnum() method has no parameters, so we don't have to worry about passing it some value.

# Signature of isalnum() method 
isalnum()





The isalnum() method returns a bool False on a string made up of any special character or symbols, except lower case or upper case alphabets or digits. Let us see a few more examples of calling the isalnum() method on all different forms of strings.



# Python - Method isalnum() Example



# Creating the first string
s1 = ('Robot2.0')

# Printing the first string
print('The first string : ', s1)

# Calling  the isalnum() method on first string object 
print('isalnum() method on first string : ', s1.isalnum())



# Creating the second string
s2 = ('The_Blue_Umbrella')

# Printing the second string
print('The second string : ', s2)

# Calling  the isalnum() method on second string object 
print('isalnum() method on second string : ', s2.isalnum())




# Creating the third string
s4 = ('Salut!')

# Printing the third string
print('The third string : ', s4)

# Calling  the isalnum() method on third string object 
print('isalnum() method on third string : ', s4.isalnum())


Output


The first string :  Robot2.0
isalnum() method on first string :  False
The second string :  The_Blue_Umbrella
isalnum() method on second string :  False
The third string :  Salut!
isalnum() method on third string :  False


Program Analysis







Please share this article -





< Prev
Next >
< String isalpha() Method
String isdecimal() Method >



Advertisement

Please Subscribe

Please subscribe to our social media channels for daily updates.


Decodejava Facebook Page  DecodeJava Twitter Page Decodejava Google+ Page




Advertisement



Notifications



Please check our latest addition

C#, PYTHON and DJANGO


Advertisement