Friday, March 30, 2018

How to check alphanumeric characters in Python Strings ?


String isalnum() Method

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

Syntax

str.isa1num()

Return Value

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

Example

#!/usr/bin/python3
str = "this2016"    # No space in this string
print (str.isalnum())

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

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

True
False




<<< index( )                                Go to Index                        isalpha( ) >>>