What is the syntax to check is a string is alphanumeric?

<string name>.isalnum()
#example
str = 'HELLOWORLD'
str2 = "abc123"
str3 = 'ao39$@'

print(str.isalnum())
print(str2.isalnum())
print(str3.isalnum())

#output
True
True
False

 

 

Advertisements