Python - String isalnum() Method


Advertisements

The string isalnum() method is used to check whether all characters of the string is alphanumeric or not. It returns true when all characters of the string is alphanumeric, else returns false. Alphanumeric characters belongs to numbers 0 - 9, letters A - Z (both uppercase and lowercase).

Syntax


string.isalnum()

Parameters

No parameter is required.

Example:

In the below example, isalnum() method to used to check whether all characters of the string is alphanumeric or not.

MyString = "Hello World!"
print(MyString.isalnum())

MyString = "HelloWorld"
print(MyString.isalnum())

Output

False

True

String Methods
Advertisements