Skip to content
Related Articles

Related Articles

Python String isalnum() Method

View Discussion
Improve Article
Save Article
  • Difficulty Level : Basic
  • Last Updated : 12 Aug, 2021

Python String isalnum() method checks whether all the characters in a given string are alphanumeric or not. Alphanumeric means a character that is either a letter or a number.

Syntax: 

string_name.isalnum() 

Parameter: 

isalnum() method takes no parameters 

Return: 

  • True: If all the characters are alphanumeric 
  • False: If one or more characters are not alphanumeric 

Example 1: Working of isalnum()

Python




# Python program to demonstrate the use of
# isalnum() method  
  
# here a,b and c are characters and 1,2 and 3
# are numbers
string = "abc123"
print(string.isalnum())
  
# here a,b and c are characters and 1,2 and 3 
# are numbers but space is not a alphanumeric 
# character
string = "abc 123" 
print(string.isalnum())

Output: 

True
False
My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!