Python Program to Check if a Character is an Alphabet or not

In this python tutorial, you will learn how to Check if a Character is an Alphabet or not using the if and else statements along with the equality operators of the python programming language.

How to Check if a Character is an Alphabet or not?

Let’s take a look at the source code , here the values are given as input by the user in the code, the <= lesser than equal to operator and the >= greater than equal to operator along with the if and else statements carry out the function.

#Python program to Check if a Character is an Alphabet or not

ch = input("Enter a character: ")
if((ch>='a' and ch<= 'z') or (ch>='A' and ch<='Z')):
    print("\n{0} is an Alphabet".format(ch))
    print("\n{0} is not an Alphabet".format(ch))




Enter a character: 
Buddy is an Alphabet
  1. Here we give the user the option to enter the values and the input values are scanned using the input function and are stored in the variable ch with the statements/strings ("Enter a character:" ) .
  2. In the STDIN section of the code editor the input values are entered.
  3. We declare the if statement with the conditions as (ch>='a' and ch<= 'z') or (ch>='A' and ch<='Z') followed by a colon :  If the conditions are met, the print  function will display the statement ("\n{0} is an Alphabet".format(ch)).
  4. If the above condition is not met the else function will be executed and the print function will display the statement ("\n{0} is not an Alphabet".format(ch)).
  5. In the above lines of code, the variables {0}  will hold the value of ch where the format function helps in variable substitution and data formatting.


  • The >= greater than and equal to operator along with the <= greater than and equal to operator is a comparison operator which returns True if the condition is satisfied, if not it returns false.
  • The input() function allows a user to insert a value into a program, it returns a string value.
  • The if and else statements evaluates whether an expression is true or false. If a condition is true, the “if” statement is executed otherwise, the “else” statement is executed.
  • The colon : at the end of the if, elif and else statement tells Python that the next line of code should only be run if the condition is true.
  • The statement for the input function are enclosed in single quotes and parenthesis.
  • The \n in the code indicates a new line or the end of a statement line or a string.
  • The print statement/string to be displayed in enclosed in double quotes.