Question: Define a function called zip (in seq_lib.py) which accepts two lists, s and t, as input arguments, and returns a new list with all pairs

 Define a function called zip (in seq_lib.py) which accepts two lists,

Define a function called zip (in seq_lib.py) which accepts two lists, s and t, as input arguments, and returns a new list with all pairs of s and t items (in that order) that have equal indices (in their respective list). Here, "pair" simply means a tuple of length two. The input lists should not be modified in any way. Finally, you should not use the built-in zip function in order to receive credit. The above implies that: (a) if the input lists do not have equal lengths, then the returned list will have length equal to that of the shortest list (since the "trailing" elements of the longer list do not have a corresponding element with equal index), (b) if any of the two input lists is empty, then the returned list will be a new empty list. Finally, the type of s and t items does not matter. For example, the function call should evaluate to [(1,a),(2,b)]. Hint Note that the desired result is the list containing all (s[i],t[i]) tuples over the sequence of common indices i, i.e., for i in 0,1,,min(len(s),len(t))1

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!