how to check if a character is alphabet in python code example
Example 1: how to check if a string is composed only of alphabets in python
str1 = "hello world. welcome to python examples."
bool = str1.isalpha()
print('str1 contains only alphabets:', bool)
//output will be False
Example 2: what does isalpha do in python
The isalpha() method returns True if all the characters are alphabet letters (a-z).
Example 3: check if string contains alphabets python
import re
print(re.search('[a-zA-Z]', "anything"))