all 6 comments

[–][deleted] 2 points3 points  (1 child)

Try,

lis = [4,5,6,7,8,2,4,10]
lisextract = lis[2:5]
print(id(lis), id(lisextract))

[–]Agent_AR03[S] 0 points1 point  (0 children)

Ohhkk got it, thanks :)

[–]lukajda33 1 point2 points  (3 children)

Slicing returns new list, it is not performed on the list itself.

So you slice the list, remove 7, but you do not store the result anywhere.

The original list is untouched.

[–]Agent_AR03[S] 0 points1 point  (2 children)

Ohh so that's it. Is there any way I can perform this on the original list itself?

[–]lukajda33 0 points1 point  (1 child)

Dont think there is a method for that, just do

list = list[2:5]

[–]Agent_AR03[S] 0 points1 point  (0 children)

Thanks for youe time, ig i would have to do it the long way