Python String Method – isalnum()

Spread the love

isalnum() Method –

isalnum() method return True if all the characters of a string is alphanumeric (i.e. alphabets or numbers). If not then it returns False.

Syntax –

string.isalnum()

Example –

In [1]: string1 = 'abc123'

In [2]: string1.isalnum()
Out[2]: True

In [3]: string2 = 'abc 123'

In [4]: string2.isalnum()
Out[4]: False

The result of second string is False because the string also contains a white space along with numbers and alphabets.

Related Posts –

  1. Python String Method – Capitalize()
  2. Python String Method – title()
  3. Python String Method – center()
  4. Python String Method – count()
  5. Python String Method – startswith()
  6. Python String Method – endswith()
  7. Python String Method – find()
  8. Python String Method – index()

Rating: 1 out of 5.

Leave a Reply