Answered step by step
Verified Expert Solution
Question
1 Approved Answer
** 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 restStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started