Python 3.7.9 (tags/v3.7.9:13c94747c7, Aug 17 2020, 18:58:18) [MSC v.1900 64 bit (AMD64)] on win32
def List_Popped(L):
L.pop(0)
return L
Li = [x for x in range(10)]
print(Li)
LiPopped = List_Popped(Li)
print(Li)
print(LiPopped)
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
[1, 2, 3, 4, 5, 6, 7, 8, 9]
[1, 2, 3, 4, 5, 6, 7, 8, 9]
I'm having trouble understanding why popping a list value inside the List_Poped function affects the list outside of it. I tried Li.copy() outside and inside List_Poped and Li is aways affected.
I want to pop the list value inside List_Poped and have LiPopped as a result without affecting Li, so I can pass the original Li to other functions. How can I do that?