
- Python 3 Basic Tutorial
- Python 3 - Home
- What is New in Python 3
- Python 3 - Overview
- Python 3 - Environment Setup
- Python 3 - Basic Syntax
- Python 3 - Variable Types
- Python 3 - Basic Operators
- Python 3 - Decision Making
- Python 3 - Loops
- Python 3 - Numbers
- Python 3 - Strings
- Python 3 - Lists
- Python 3 - Tuples
- Python 3 - Dictionary
- Python 3 - Date & Time
- Python 3 - Functions
- Python 3 - Modules
- Python 3 - Files I/O
- Python 3 - Exceptions
How to check if a character in a string is a letter in Python?
You can use the isalpha() method from string class. It checks if a string consists only of alphabets. You can also use it to check if a character is an alphabet or not. For example, if you want to check if char at 5th index is letter or not,
>>> s = "Hello people" >>> s[4].isalpha() True
You can also check whole strings, if they are alphabetic or not. For example,
>>> s = "Hello people" >>> s.isalpha() False >>> "Hello".isalpha() True
- Related Articles
- How to check if a given character is a number/letter in Java?
- How to check if first character in a cell is a letter or number in Excel?
- How to check if a character is upper-case in Python?
- Program to check if a string contains any special character in Python
- How to check if a string has at least one letter and one number in Python?
- How to check if a string is alphanumeric in Python?
- How to check if a string in Python is in ASCII?
- How to check if a string is a valid keyword in Python?
- Python program to check if a string contains any unique character
- Check whether the Unicode character is a lowercase letter in C#
- Check if a string is Colindrome in Python
- How to check if type of a variable is string in Python?
- PHP program to check if a string has a special character
- Check if frequency of character in one string is a factor or multiple of frequency of same character in other string in Python
- C# Program to check if a character is a whitespace character

Advertisements