Advanced python question middle number

**I got the right answer because I got help solving it but im having trouble understanding how the solution was came too, why the the program work in the way it work. seeking better understanding **

Create a function named remove_middle which has three parameters named lst , start , and end .

The function should return a list where all elements in lst with an index between start and end (inclusive) have been removed.

For example, the following code should return [4, 23, 42] because elements at indices 1 , 2 , and 3 have been removed:

remove_middle([4, 8 , 15, 16, 23, 42], 1, 3)

Hi there.

Can you show us the code which is confusing you, and also explain which bit(s) are confusing you? :slight_smile:

If you write down the input your function receives on paper - can you produce the answer manually?
The answer to that is almost certainly yes, obviously.
So then, you already have a strategy. Maybe you need to study what you do in some detail, and then you can write those things down in code so that the computer can do the same thing.
You might not know how to do all those things, some of the actions you may need to break down into smaller steps, maybe some actions are things that make sense to do with a list but you don’t know how python’s list type happens to expose that behaviour, but that still means you know the action and can then google for how to carry out that particular action, or read the documentation for the things involved to find out what you can do with them and pick things that match what you need.

1 Like