isalpha() String Method in Python with Examples
isalpha()
method returns True
if the string is alphabetic string otherwise it returns False
.
A string is alphabetic if all characters in the string are alphabetic and there is at least one character in the string.
Example 1: isalpha() String Method
message = 'welcome'
if message.isalpha():
print('"%s" is alphabetic string.' %(message))
else:
print('"%s" is not alphabetic string.' %(message))
Output
"welcome" to python is alphabetic string.
Example 2: isalpha() String Method
message = 'welcome to python'
if message.isalpha():
print('"%s" is alphabetic string.' %(message))
else:
print('"%s" is not alphabetic string.' %(message))
Output
"welcome to python" is not alphabetic string. Note: this is not alphabetic since there is space in string.
Related String Methods