In Python IDLE: How would I write a function for the problem in the attached image?
Extracted text: interleaved Write a function interleaved that accepts two sorted sequences of numbers and returns a sorted sequence of all numbers obtained by interleaving the two sequences. Guidelines: • each argument is a list • assume that each argument is sorted in non-decreasing order (goes up or stays the same, never goes down) • you are not allowed to use sort or sorted (or any other form of sorting) in your solution • you must interleave by iterating over the two sequences simultaneously, choosing the smallest current number from each sequence. Sample usage: 1 >>> interleaved( [-7, -2, -1], [-4, 0, 4, 8]) 2 [-7, -4, -2, -1, 0, 4, 8] 3 >>> interleaved( [-4, 0, 4, 8], [-7, -2, -1]) 4 [-7, -4, -2, -1, 0, 4, 8] >>> interleaved( [-8, 4, 4, 5, 6, 6, 6, 9, 9], [-6, -2, 3, 4, 4, 5, 6, 7, 8]) [-8, -6, -2, 3, 4, 4, 4, 4, 5, 5, 6, 6, 6, 6, 7, 8, 9, 9] 7 >>> interleaved( [-3, -2, 0, 2, 2, 2, 3, 3, 3], [-3, -2, 2, 3]) 8 [-3, -3, -2, -2, 0, 2, 2, 2, 2, 3, 3, 3, 3] 9. >>> interleaved( [-3, -2, 2, 3], [-3, -2, 0, 2, 2, 2, 3, 3, 3]) 10 [-3, -3, -2, -2, 0, 2, 2, 2, 2, 3, 3, 3, 3] 11 >>> interleaved([1,2,2],[]) 12 [1, 2, 2] 13 >>> interleaved([],[1,2,2]) 14 [1, 2, 2] 15 >>> interleaved ([],[]) 16 [] 17 >>> interleaved( list(range(-2,12,3)), list(range (20,50,5)) ) 18 [-2, 1, 4, 7, 10, 20, 25, 30, 35, 40, 45] 19 >>> interleaved( list(range (20,50,5)), list(range(-2,12,3)) )==[-2, 1, 4, 7, 10, 20, 25, 30, 35, 40, 45] 20 True