

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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 Questions & Answers
- How to check if a given character is a number/letter in Java?
- How to check if a character is upper-case in Python?
- How to check if a string is alphanumeric in Python?
- C# Program to check if a character is a whitespace character
- How to check if a string is a valid keyword in Python?
- Check if a string is Colindrome in Python
- How to check if a string in Python is in ASCII?
- Python - Check if a variable is string
- Program to check if a string contains any special character 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 character is alphanumeric in Arduino
- Check if a character is printable in Arduino
- Check if input is a number or letter in JavaScript?
- PHP program to check if a string has a special character
Advertisements