Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

python Compound Words Function Name: compoundWords Parameters: wordsList ( list ), num ( int ) Returns: matchedWords ( list ) Description: Write a function that

python

image text in transcribed

Compound Words Function Name: compoundWords Parameters: wordsList ( list ), num ( int ) Returns: matchedWords ( list ) Description: Write a function that takes in a list of strings and an integer. The function should create a list of strings of length the integer passed in (num) by concatenating the strings in the original list together. If the empty list is passed in, the function should return None. Note: The function should ignore duplicates. In the first example below, the words firehose and hosefire are both of length 8. However, the function only outputs firehose because these two strings are considered equivalent. In general, the function should only concatenate a string with strings that occur later (at higher indices) in the list. >>> wordsList = ["fire", "god", "speed", "trucks", "hose"] >>> print (compoundWords (wordsList, 8)) ['firehose', 'godspeed'] >>> wordsList = ["school", "time", "books", "work", "food"] >>> print(compoundWords (wordsList, 10)) ['schooltime', 'schoolwork', 'schoolfood']

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions

Question

How do you add two harmonic motions having different frequencies?

Answered: 1 week ago