Python Program to Count the Number of Vowels Present in a String using Sets

Bydiwas

Python Program to Count the Number of Vowels Present in a String using Sets

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
vowels="aeiou"
for letter in s:
if letter in vowels:
cnt = cnt+1
print("Count of the vowels is:") print(cnt)

output:

Explanation:

  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.

About the author

diwas administrator

1 Comment so far

https://sablonkaossatuanbandung88.blogspot.comPosted on12:49 pm - Jan 29, 2019

Niϲe post. I was checking continuously this blog andd I’m impressed!
Еxtremely usefսl info specifіcally the
lasst part 🙂 I care for such nfo а lot. I ѡas
looking for this particular info for a very long time.
Thank you and good luck. https://sablonkaossatuanbandung88.blogspot.com/

Leave a Reply