In this article, I will take you through how to write a Python program to check whether the given alphabet is a vowel or not. Vowels are one of the categories of speech sounds. We have all studied about them in English in junior classes as the vowels are a, e, i, o, u. So in this article, you will learn how to check whether a given alphabet is a vowel or not and whether a given word has vowels or not.
Python Program to Check Vowel
There are hundreds of ways to write a Python program to check whether a given alphabet is a vowel or not and whether the given word has vowels or not. Here is a very simple program that is very easy to understand. If you are a beginner in Python, you can easily understand the code below:
a = ["a", "e", "i", "o", "u"] user_input = input("Enter any alphabet : ") if user_input.lower() in a: print("It is a vowel") else: print("It is not a vowel")
Enter any alphabet : a It is a vowel
So the alphabets a, e, i, o, u are known as vowels in English, that are what I have stored in a list at the start of the program. So first, I have simply created a Python list as “a” by storing all the vowels in it. Then I am taking a user input. Then I have just used an if-else statement that if the user input will have any alphabet that is available in the list “a” or will have any word which contains any alphabet available in the list a then the program will return “It is a vowel” as an output. Otherwise (the else command) the program will return “It is not a vowel as an output”.
One thing to notice in the above code is that I have used user_input.lower so that the moment the user gives an input it will be converted into a lower case, otherwise we have to create a longer list as [a, A, b, B, and so on].
So I hope you liked this article on how to check if the given alphabet is vowel or not. Feel free to ask your valuable questions in the comments section below.