Today we are going to share a Python program to count the number of each vowel. If you are a python beginner and want to start learning the python programming, then keep your close attention in this tutorial as I am going to share a Python program to count the number of each vowel.
To increase your Python knowledge, practice all Python programs, here is a collection of 100+ Python problems with solutions.
To increase your Python knowledge, practice all Python programs, here is a Collection of 100+ Python problems with solutions.
Copy the below python program and execute it with the help of python compiler.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | # string of vowels vowels = 'aeiou' # change this value for a different result ip_str = 'Hello, have you tried our tutorial section yet?' # make it suitable for caseless comparisions ip_str = ip_str.casefold() count = {}.fromkeys(vowels,0) #count the vowels for char in ip_str: if char in count: count[char] += 1 print(count) |
{‘u’: 3, ‘a’: 2, ‘o’: 5, ‘e’: 5, ‘i’: 3}
If you like FreeWebMentor and you would like to contribute, you can write an article and mail your article to [email protected] Your article will appear on the FreeWebMentor main page and help other developers.