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 float() Built in Function

Python String encode() Method

Python str() Built in Function

Python String format_map() Method

Python String format() Method