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:

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