Python string isalpha() Method

In this tutorial, We will see the python string isalpha() method with examples.

isalpha() Method

The isalpha() method is one of the methods in a python string. Python string isalpha() method checks all the characters in the string are alphabets or not.

  • Return True, If all the characters are alphabets.
  • Return False, If all the characters are not alphabets.
Syntax of Python string isalpha() method

This is the syntax of the python string isalpha() method.

string.isalpha()
Example of the Python string isalpha() method
#Example 1 

text = "python is a programming language"
#check the text contains only alphabetic characters or not 
print(text.isalpha())
#output : True
#Example 2

text = "python isalpha() method"
print(text.isalpha())
# ( ) is not alphabets.
#output: False

#Exmaple 3

message = "hello WORLD 123"
msg = message.isalpha()
print(msg)
#123 is not alphabets.

#output: False

Program: Take a string from the user and check all the characters are alphabet or not.

message = input("Enter the message")
msg = message.isalpha()
print(msg)

Related Posts