I am confused why this short snippet to remove specific pairs from a list fails:
g = [[7, 11], [7, 8], [3, 10], [3, 8], [8, 9], [11, 10], [11, 2],
[11, 9]]
u = 3
g_cpy = g
for e in g_cpy:
if u == e[0]:
g.remove(e)
print g
It does not remove the entry [3,8], but it does remove [3,10]. What am I missing?