Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
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