Question: ** using python 4. Write a function called most_consonants(words) that takes a list of strings called words and returns the string in the list with
** using python
4. Write a function called most_consonants(words) that takes a list of strings called words and returns the string in the list with the most consonants (i.e., the most letters that are not vowels). You may assume that the strings only contain lowercase letters. For example >>> most_consonants(['python', 'is', 'such', 'fun']) python' >>>most_consonants(C'oooooooh', 'i', 'see 'now']) now The function that you write should use the num_vowels function from lecture as a helper function, along with either a list comprehension or recursion. Copy num_vowels into your ps3pr2.py file, adjusting the indentation as needed. Note: You don't need to worry about cases in which two or more words are tied for the most consonants def num vowels (s): " "" returns the number of vowels in the string s input: s is a string of 0 or more lowercase letters if s': return 0 else: num in rest num vowels (s[ 1:]) if s[0] in 'aeiou': return 1 + num in rest else: return 0+ num in rest
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
