.isalnum()

Anonymous contributor's avatar
Anonymous contributor
Published Sep 27, 2023
Contribute to Docs

The .isalnum() string method takes in a string and returns True if all the characters are alphanumeric (A-Z, a-z, 0-9). Otherwise, it returns False if the string contains any non-alphanumeric characters (e.g. @ # $ % - *).

Syntax

my_string.isalnum()

This method does not have any parameters.

Example

The examples below use .isalnum() to check if all the characters are alphanumeric:

my_string = "AlphaNumeric001"
print(my_string.isalnum())

The code above will result in the following output:

True

Codebyte Example

The code below is runnable and uses the .isalnum() method:

Code
Output
Loading...

All contributors

Contribute to Docs

Learn Python on Codecademy