Advertisement
Nenogzar

Untitled

Nov 13th, 2023
960
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.62 KB | None | 0 0
  1. def vowel_count(list_of_strings):
  2.   """Returns a dictionary of vowel counts for the given list of strings.
  3.  
  4.  Args:
  5.    list_of_strings: A list of strings.
  6.  
  7.  Returns:
  8.    A dictionary, keyed on the five vowels a, e, i, o, and u. The value for each
  9.    should be the total number of entries in the list which contain at least a
  10.    single copy of that vowel.
  11.  """
  12.  
  13.   vowel_counts = {}
  14.   for vowel in ['a', 'e', 'i', 'o', 'u']:
  15.     vowel_counts[vowel] = 0
  16.  
  17.   for string in list_of_strings:
  18.     for vowel in ['a', 'e', 'i', 'o', 'u']:
  19.       if vowel in string:
  20.         vowel_counts[vowel] += 1
  21.  
  22.   return vowel_counts
  23.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement