Answered step by step
Verified Expert Solution
Link Copied!

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

image text in transcribed** 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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2017 Skopje Macedonia September 18 22 2017 Proceedings Part 3 Lnai 10536

Authors: Yasemin Altun ,Kamalika Das ,Taneli Mielikainen ,Donato Malerba ,Jerzy Stefanowski ,Jesse Read ,Marinka Zitnik ,Michelangelo Ceci ,Saso Dzeroski

1st Edition

3319712721, 978-3319712727

More Books

Students also viewed these Databases questions

Question

5. Understand how cultural values influence conflict behavior.

Answered: 1 week ago