I am trying to complete the following challenge:
Create a function named
remove_middle which has three parameters named
start , and
The function should return a list where all elements in
lst with an index between
end (inclusive) have been removed.
For example, the following code should return
[4, 23, 42] because elements at indices
2 , and
3 have been removed:
remove_middle([4, 8 , 15, 16, 23, 42], 1, 3)
Now I understand the solution given but I wanted to try and do my own solution using a while loop and this is the code I have.
i = start
while i <= end:
lst.pop(i) i += 1
When I try the code out it return [0,1,4,6] but it should return [0,1,5,6,7] any help would be appreciated.