I have a list named wins I want to remove all the elements from wins list using list.remove function but out of 12 elements only six elements are remaining
wins = [[0,0,0,1,0,2,0,3,0,4],[1,0,1,1,1,2,1,3,1,4], [2,0,2,1,2,2,2,3,2,4],
[3,0,3,1,3,2,3,3,3,4],[4,0,4,1,4,2,4,3,4,4],
[0,0,1,0,2,0,3,0,4,0], [0,1,1,1,2,1,3,1,4,1], [0,2,1,2,2,2,3,2,4,2],
[0,3,1,3,2,3,3,3,4,3],[0,4,1,4,2,4,3,4,4,4],
[0,0,1,1,2,2,3,3,4,4],[4,4,3,3,2,2,1,1,0,0]]
for win in wins:
wins.remove(win)
print("wins", wins)
Output
wins [[1, 0, 1, 1, 1, 2, 1, 3, 1, 4], [3, 0, 3, 1, 3, 2, 3, 3, 3, 4], [0, 0, 1, 0, 2, 0, 3, 0, 4, 0], [0, 2, 1, 2, 2, 2, 3, 2, 4, 2], [0, 4, 1, 4, 2, 4, 3, 4, 4, 4], [4, 4, 3, 3, 2, 2, 1, 1, 0, 0]]
try
wins = [[0,0,0,1,0,2,0,3,0,4],[1,0,1,1,1,2,1,3,1,4], [2,0,2,1,2,2,2,3,2,4],
[3,0,3,1,3,2,3,3,3,4],[4,0,4,1,4,2,4,3,4,4],
[0,0,1,0,2,0,3,0,4,0], [0,1,1,1,2,1,3,1,4,1], [0,2,1,2,2,2,3,2,4,2],
[0,3,1,3,2,3,3,3,4,3],[0,4,1,4,2,4,3,4,4,4],
[0,0,1,1,2,2,3,3,4,4],[4,4,3,3,2,2,1,1,0,0]]
for win in wins:
wins.remove(win)
print("wins", wins)
expecting
wins []
but output
wins [[1, 0, 1, 1, 1, 2, 1, 3, 1, 4], [3, 0, 3, 1, 3, 2, 3, 3, 3, 4], [0, 0, 1, 0, 2, 0, 3, 0, 4, 0], [0, 2, 1, 2, 2, 2, 3, 2, 4, 2], [0, 4, 1, 4, 2, 4, 3, 4, 4, 4], [4, 4, 3, 3, 2, 2, 1, 1, 0, 0]]