Python String isalnum() Method

The isalnum() method is a string method that returns True if all the characters in the string are alphanumeric, meaning letters (a-z) and numbers (0-9).

For example:


name = "Alice123"
print(name.isalnum())

# prints True

The method returns False if the string contains any non-alphanumeric characters, such as spaces, punctuation marks, symbols, etc.

For example:

name = "Alice 123"
print(name.isalnum())

# prints False

If you have any questions about this code, you can drop a line in comment.

Comments

Popular posts from this blog

Python chr() Built in Function

Stock Market Predictions with LSTM in Python

Collections In Python

Python Count Occurrence Of Elements

Python One Liner Functions