Learn about Python program to check character is vowel or consonant in the below code example. Also, refer to the comments in the code snippet to get a detailed view about what’s actually happening.
Contents
Python program to check character is vowel or consonant
The user is prompted to enter a character in this program. The program examines if the entered letter is equal to lowercase or uppercase vowels; if it is, the program writes a message indicating that the character is a Vowel; otherwise, the program prints a message indicating that the character is a Consonant.
Program:
# Python program to check character is vowel or consonant
# character input
ch = input('Enter any character: ')
# check vowel or constant and display result
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 any character: a
a is a Vowel
Hope above code works for you and Refer the below Related Codes to gain more insights. Happy coding and come back again.
Similar Code : How to Divide Two Columns in Pandas