The isalnum method
The isalnum method checks that the characters of a string are only letters and numbers. Nothing is passed to the method parameters. The method returns the values True or False.
Syntax
string.isalnum()
Example
Let's check that the string consists only of letters and numbers:
txt = 'abcadea12'
print(txt.isalnum())
Result of code execution:
True
Example
Let the line now contain other characters:
txt = '@abcadea12'
print(txt.isalnum())
Result of code execution:
False