.isalnum()
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:
All contributors
- Anonymous contributor
Contribute to Docs
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.
Learn Python on Codecademy
- Skill path
Analyze Data with Python
Learn to analyze and visualize data using Python and statistics.Includes 8 CoursesWith CertificateIntermediate13 hours - Course
Learn Python 3
Learn the basics of Python 3.12, one of the most powerful, versatile, and in-demand programming languages today.With CertificateBeginner Friendly23 hours