FREE E LEARNING PLATFORM
HOMEEXCEPTIONSOOPSJVMINTRO
 

Program to Check Vowel or Consonant




In this post, we will write a Python program to check whether the entered character is vowel or consonant.

Python code

In this program, user is asked to input a character. The program checks whether the entered character is equal to the lowercase or uppercase vowels, if it is then the program prints a message saying that the character is a Vowel else it prints that the character is a Consonant.

# taking user input
ch = input("Enter a character: ")

if(ch=='A' or ch=='a' or ch=='E' or ch =='e' or ch=='I'
 or ch=='i' or ch=='O' or ch=='o' or ch=='U' or ch=='u'):
    print(ch, "is a Vowel")
else:
    print(ch, "is a Consonant")

Output

Enter a character: a
a is a Vowel






Leave Comment