Question: python programming 3.x. We want to transfer data between multiple lists while rearranging their order. We want to: 1.) Take a slice of the numbers

python programming 3.x.

We want to transfer data between multiple lists while rearranging their order. We want to:

1.) Take a slice of the numbers from list1 with a given range

2.) Add them in reverse order to another list, list2

3.) Removing them from list1

Lets take one scenario:

1. List1 is [1, 2, 3, 4, 5, 6, 7, 8, 9]

2. We want to take the range of 4:7

3. list2 already has [100, 200]

After this operation, list2 would be: {100, 200, 7, 6, 5}

To accomplish this, let us write transform that takes as arguments list1, list2, r1, and r2 It will: -

_Remove items from list1 using a slice r1:r2

- Append them onto list2 in reverse order

- Return the resulting list In our scenario above we would call transform as follows:

transform(list1, list2, 4, 7)

Write a Python program wherein the main you will ask for the two lists and a range to slice over. The program should then call the transform function and update list2 as required above. The main should provide a print out for the updated list2. Assume the user is smart and enters correct values.

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!