Python string | isalnum ()

Alphanumeric : character that is a letter or number

Syntax :

string_name.isalnum ()
string_name is the name of the string

Parameter: isalnum () method takes no parameters

Return :

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

Below is the implementation of the isalnum () method in Python.

# Python program to demonstrate usage
# 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 the space is not alphanumeric
# character

string = "abc 123"  

print (string.isalnum ()) 

Output:

 True False