Question: use python language. Write a function drop_long_words(sentence, max_len) that takes as a parameter a string sentence consisting only of words separated by a single space

use python language. Write a function drop_long_words(sentence, max_len) that takes as a parameter a string sentence consisting only of words separated by a single space and an integer max_len. The function returns the sentence with all words greater than max_len omitted. The returned sentence should also consist of words separated by a single space.

Hint: the split method of a string should be useful.

For example:

Test Result
print(drop_long_words("This is a fancy bit of work methinks", 4))
This is a bit of work
print(drop_long_words("One two buckle my shoe", 4))
One two my shoe

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!