I have this small loop, which loops over some numbers, then loops over a list of list. If the number within the first loop is within the loop, it is removed. However, I noticed that this ie being removed from the list of list and not the list from withe loop. Code below
num_list = [[1,2,3,4,5], [1,2,3,4,5]]
for num in [1,2,3,4,5]:
for pimp in num_list:
if num in pimp:
pimp.remove(num)
print(pimp)
Yet, it works as expected in the following code:
for num in [1,2,3,4,5]:
for pimp in [[1,2,3,4,5], [1,2,3,4,5]]:
if num in pimp:
pimp.remove(num)
print(pimp)
What is the difference? What am I missing here?