Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Python programming | 75.5% it through CodeLoad and by creating your own test cases Part I: Interleave: Fix Errors) (20 points) In the Fix Error

image text in transcribed

Python programming

| 75.5% it through CodeLoad and by creating your own test cases Part I: Interleave: Fix Errors) (20 points) In the Fix Error type of problems, you will be given a problem as usual, but with a buggy "solution" provided for you. Your task is to find the ermors) and make the function work properly. Note that you are free to just rewrite CSE 101-Fall 2017 Lab #3 Page I the solution yourself, but as the problems get harder, it might be easier to find the ermor rather than rewrite the whole function. Fix the function interleave () which takes as its only argument a list called nums, which contains integers sub-lists. Create a new list by interleaving the lists of integers and return the interleaved list. This process is most easily understood by looking at an cx ample. Example: Let's consider a list of two sub-lists, with three elements per sub-list [11, 2,31, 14,5, 61 The first clement of the first list (denoted nums [0j 0]will be the first element of the new list. .The first element of the second list (denoted nums 111 10]) will be the second element of the new list The second clement of the first list idenoted nums [0] 1]) will the third clement of the new list . The second element of the second list (denoted nums[11 [1) will he the fourth element of the new list. . The third element of the first list (denoted nums [ [2] ) will the fifth element of the new list. The third element of the second list (denoted numa 11 [2])will be the sixth element of the new list. The final list will be: 11,4,2,5, 3, 6] Note: You may assume that all sub-lists in nums will have same number of elements. If the list or the sub-lists are empty list(s), the return value should be an empty list Examples: Function Call Return Value 1, 4, 7, 2, 5, 8, 3, 6, 9) interleave([[1, 2, 31, 14, 5, 6), [7, 8, 9111 interleave (I[0,1,0, (1,0,0), [0, 0,1]]) interleave (I [1, 2], 13,41, I5, 61, 17,81. 9, 01 0, 2, 0, 1, 0, 0, 0, 0, 11 L,3, 5,7, 9, 2, 4, 6, B, Oj Remember: Codel oad has additional tests for you to uy! up against harder tests. Upload your code there and see how your code matches

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Driven Web Sites

Authors: Mike Morrison, Joline Morrison

1st Edition

061901556X, 978-0619015565

Students also viewed these Databases questions

Question

can adapttaion cause insensitivity in motion detectors of V1

Answered: 1 week ago