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
pythonstring.isalnum()
Example
Let's check that the string consists only of letters and numbers:
pythontxt = 'abcadea12'
print(txt.isalnum())
Result of code execution:
pythonTrue
Example
Let the line now contain other characters:
pythontxt = '@abcadea12'
print(txt.isalnum())
Result of code execution:
pythonFalse