Python Program to Count the Number of Each Vowel ( Using a list and a dictionary comprehension)
# Using dictionary and list comprehension
ip_str = 'Hello, have you tried our tutorial section yet?'
# make it suitable for caseless comparisions
ip_str = ip_str.casefold()
# count the vowels
count = {x:sum([1 for char in ip_str if char == x]) for x in 'aeiou'}
print(count)
Output
{'o': 5, 'i': 3, 'a': 2, 'e': 5, 'u': 3}
