Python 3 - String isalnum() Method


Advertisements

Description

The isalnum() method checks whether the string consists of alphanumeric characters.

Syntax

Following is the syntax for isalnum() method −

str.isa1num()

Parameters

NA

Return Value

This method returns true if all characters in the string are alphanumeric and there is at least one character, false otherwise.

Example

The following example shows the usage of isalnum() method.

#!/usr/bin/python3

str = "this2016"  # No space in this string
print (str.isalnum())

str = "this is string example....wow!!!"
print (str.isalnum())

Result

When we run the above program, it produces the following result −

True
False
python_strings.htm
Advertisements