
- Python Basic Tutorial
- Python - Home
- Python - Overview
- Python - Environment Setup
- Python - Basic Syntax
- Python - Comments
- Python - Variables
- Python - Data Types
- Python - Operators
- Python - Decision Making
- Python - Loops
- Python - Numbers
- Python - Strings
- Python - Lists
- Python - Tuples
- Python - Dictionary
- Python - Date & Time
- Python - Functions
- Python - Modules
- Python - Files I/O
- Python - Exceptions
- Python Advanced Tutorial
- Python - Classes/Objects
- Python - Reg Expressions
- Python - CGI Programming
- Python - Database Access
- Python - Networking
- Python - Sending Email
- Python - Multithreading
- Python - XML Processing
- Python - GUI Programming
- Python - Further Extensions
- Python Useful Resources
- Python - Questions and Answers
- Python - Quick Guide
- Python - Tools/Utilities
- Python - Useful Resources
- Python - Discussion
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Python String isalpha() Method
The python string isalpha() method is used to check whether the string consists of alphabets. This method returns true if all the characters in the input string are alphabetic and there is at least one character. Otherwise, it returns false.
Alphabetic characters are those characters defined in the Unicode character database as “Letter”, i.e., those with general category property being one of “Lm”, “Lt”, “Lu”, “Ll”, or “Lo”. Note that this is different from the “Alphabetic” property defined in the Unicode Standard.
Let us look into this function with more details in the following section.
Syntax
Following is the syntax for the python string isalpha() method −
str.isalpha()
Parameters
The python string isalpha() method doesnot contain any parameters.
Return Value
The python string isalpha() method returns true if all characters in the string are alphabetic and there is at least one character and false otherwise.
Example
The lowercase and uppercase alphabets come under alphabetic characters. The other characters such as '!'. '@', ... are not considered as alphabetic.
#!/usr/bin/python str = "Hello!welcome" result=str.isalpha() print("Are all the characters of the string alphabetic?", result)
On executing the above program, the following output is generated -
Are all the characters of the string alphabetic? False
Example
Only the lowercase and uppercase alphabets come under alphabetic characters.
The following is an example of the python string isalpha() method. In this program, a string "Welcome" is created and the isalpha() function is invoked.
#!/usr/bin/python str = "Welcome" result=str.isalpha() print("Are all the characters of the string alphabetic?", result)
The following is the output obtained by executing the above program -
Are all the characters of the string alphabetic? True
Example
Only the lowercase and uppercase alphabets come under alphabetic characters. Even an empty space " " is not considered as alphabetic.
#!/usr/bin/python str = "welcome " result=str.isalpha() print("Are all the characters of the string alphabetic?", result)
The following output is obtained by executing the above program -
Are all the characters of the string alphabetic? False
Example
Only the lowercase and uppercase alphabets come under alphabetic characters.
#!/usr/bin/python str = "aBCD" result=str.isalpha() print("Are all the characters of the string alphabetic?", result)
The above program, on executing, displays the following output -
Are all the characters of the string alphabetic? True
Example
The lowercase alphabets and uppercase alphabets are considered as alphabetic characters. Even the numbers and empty spaces are not considered as alphabetic.
#!/usr/bin/python str = "Welcome to Tutorialspoint12" result=str.isalpha() print("Are all the characters of the string alphabetic?", result)
The output of the above program is displayed as follows -
Are all the characters of the string alphabetic? False