Answered step by step
Verified Expert Solution
Question
1 Approved Answer
python Compound Words Function Name: compoundWords Parameters: wordsList ( list ), num ( int ) Returns: matchedWords ( list ) Description: Write a function that
python
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
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