Question: 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
Get step-by-step solutions from verified subject matter experts
