Check if a Character in a String is a Letter (Python)

The quickest way to check whether a character in a string is a letter is to use the str.isalpha() function.

This code is going to return True because ‘a’ is a letter.

Check all characters inside a string

If you want to check the entire string for alphanumerical characters, you can use this code:

If you run it, it’s going to return the following output:

Y True
e True
a True
r True
  False
1 False
9 False
8 False
4 False
! False

Only the first four characters inside the string are letters, and the result shows us that.