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.

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

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

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

#Exmaple 3

message = "hello WORLD 123"
msg = message.isalpha()
#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()

Related Posts