Site icon i2tutorials

Isalnum() method in Python String Module

Isalnum() method in Python String Module

isalnum method returns the outputas TRUE only if the string is alphanumeric or alphabetical or numerical. It does not allow any other special characters.

If the string has any special characters (Punctuation symbols that includes space) the output is returned as FALSE.


Syntax

str.isalnum()


Example-1:

When the given string is alphanumeric

text="PythonisaPopularProgramminglanguage"
x=text.isalnum()
print(x)


Output:


Example -2:

When the given string is non-alphanumeric

text="Python is a Popular Programming language"
x=text.isalnum()
print(x)


Output:


Exit mobile version