Menu

[solved]-Write Function Mostconsonants Words Takes List Strings Returns String List Consonants Assu Q39029511

Write function most_consonants(words) that takes list of stringsand returns string in list with the most consonants. Assume stringsonly contain lowercase letters. Ex:

>>> most_consonants([‘python’, ‘is’, ‘such’, ‘fun’])’python’>>> most_consonants([‘oooooooh’, ‘i’, ‘see’, ‘now’])’now’The function that you write should use num_vowels function as a helper function, along with list comprehension or recursion:def num_vowels(s): 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

The function I have written now to call upon num_vowels justkeeps returning the string in list with the most VOWELS no matterhow I format it. I tried to re-write num_vowels but I keep gettingerrors about max recursion reached. Ex:

>>> most_consonants([‘oooooooh’, ‘i’, ‘see’, ‘now’])–> ‘oooooooh’ instead of ‘now’

Expert Answer


Answer to Write function most_consonants(words) that takes list of strings and returns string in list with the most consonants. As… . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *