This time I want to get the following result by using slice. However, I could not manage it. Is there a negative version of List[3:5] in this scenario?
Input:
List=[1,2,3,4,5,6,7]
Output:
List =[1,2,5,6,7]
CodePudding user response:
First off List[3:5] = [4, 5]
so the "negative" version would be [1, 2, 3, 6, 7]
. You can produce that with:
List[:3] List[5:]
CodePudding user response:
List[:3] List[5:]
Hopefully that's not the real name of the variable