To count the number of vowels in a string we need to do following steps.

  1. reading the string from the user.
  2. create a set of string containing vowels
  3. compare the given string to the set of vowels.
  4. count the number of vowels if match found.
  5. print the result.

For that source code is given below:

s=input("Enter string:") 
cnt = 0
for letter in s:
if letter in vowels:
cnt = cnt+1
print("Count of the vowels is:") print(cnt)



  1. user have to input the string.
  2. program will compare the given string with (aeiou ) inside for loop.
  3. if match found cnt will increment and print the output.

One thought on “Python Program to Count the Number of Vowels Present in a String using Sets”

Leave a Reply

Your email address will not be published. Required fields are marked *