Hi fellow coders,
I am currently doing the Learn Python 3 course and I have a question regarding the Advanced Python Code Challenges: Lists task number 2.
In the def remove_middle(lst, start, end): function, for subtask 3, I don’t understand why we need to add end+1 to get all the elements after the ending index (inclusive) instead of simply typing end:.
def remove_middle(lst, start, end): **
** return lst[:start] + lst[end+1:]
The whole task is the following:
- Define the function to accept three parameters: the list, the starting index, and the ending index
- Get all elements before the starting index
- Get all elements after the ending index
- Combine the two partial lists into the result
- Return the result
Is anyone able to shed any light?
Thanks a bunch!!