Question: using basic python -) [40 marks] Write a function named alternate that takes two lists and returns a new list containing alternating elements of the

using basic python
using basic python -) [40 marks] Write a function named alternate that

-) [40 marks] Write a function named alternate that takes two lists and returns a new list containing alternating elements of the given lists. For example, a call to alternate([1, 2], ['a', 'b']) should return [1, 'a', 2, 'b']. If the given lists have different lengths, simply append the remaining elements of the longer list to the new list (the result). Please see the examples below. result = alternate([1, 2], ['a', 'b']) print(result) [1, 'a', 2, 'b'] result = alternate([1, 2, 3, 4], ['a', 'b']) print(result) [1, a', 2, 'b', 3, 4] result = alternate([1, 2], ['a', b', ' cd']) print(result) [1, 'a', 2, 'b', 'c','d'] result = alternate([], ['a', 'b', ' cd']) print(result) ['a', 'b', 'c','d'] co

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!