FAQ: Code Challenge: Lists - Remove Middle


This took me a while to figure out. I finally get it now. The +1 at the end is to adjust for the final number “end” to be removed from the function. To some of the other threads, I was tempted to use additional functionality, but I assume there is a method to his madness. This is so far the hardest exercises, primarily because of the wording.


im also having trouble with this, i dont think there was a lesson introducing some of this subjects or at least i cant remember, i have to look at the answer.

#Write your function here
def remove_middle(lst, start, end):
return lst[:start] + lst[end+1:]

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

also, i dont understan what the 1, 3 mean

    remove_middle(lst, start, end)
                  [ ],   1  ,  3


#Write your function here

def remove_middle(lst, start, end):
del lst[start:end+1]
return lst


It’s not just you, this section of challenges was very poorly organized. Every single one of them requires knowledge that was not taught in the lessons. Maybe they’re trying to teach us to be resourceful?


So if we can use the “+” to add things from a list into another list why cant we use the minus symbol ( - ), in order to remove an area of a list we dont want?


Bro how much did this take for you to write that code? the area_1 is start but the area_2 gives negative number always. i dont know how the fk this code works but it does lol nice


The plus sign is a concatenation operator. Concatenation is a processing of linking two objects: a string to a string, or a list to a list. There is no operation to minus an element from a list, save manual iteration or using a method such del(), .pop(), or .remove().