Answered step by step
Verified Expert Solution
Question
1 Approved Answer
in python Write a function word_mix(wordlist1, wordlist2) that takes as parameters two lists that contain strings. Have the function return a single string that is
in python
Write a function word_mix(wordlist1, wordlist2) that takes as parameters two lists that contain strings. Have the function return a single string that is the result of concatenating alternating strings from each list, starting with wordlist1, inserting a space character between strings. If the lists do not contain the same number of strings, then continue concatenating strings from the list with more items. Make sure that your final string does not have an extra space character at the end. Hints: - You may have to have multiple loops to handle the case where the lists have unequal lengths. - There are several ways to deal with an extra space at the end of the string. These include an if statement, slicing, or certain string methods for those of you reading ahead. You are welcome to add an if __ name _ == '_main __' block and test cases for this and all functions in this assignment but this is not required. Examples (text in bold is returned): word_mix (['the', 'brown'], ['quick', 'fox']) 'the quick brown fox' > word_mix (['the', 'brown', 'jumped', 'over'], ['quick', 'fox']) 'the quick brown fox jumped over' > word_mix (['the', 'brown'], ['quick', 'fox', 'jumped', 'over', 'the ', 'lazy', 'dogs']) 'the quick brown fox jumped over the lazy dogsStep 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