item = 1
test_list = [1,1, 3, 4, 6, 5, 1,2]
for i in test_list:
if(i == item):
test_list.remove(i)
print(test_list)
Expected otuput = [3, 4, 6, 5, 2]
But it is giving = [3, 4, 6, 5, 1, 2]
item = 1
test_list = [1,1, 3, 4, 6, 5, 1,2]
for i in test_list:
if(i == item):
test_list.remove(i)
print(test_list)
Expected otuput = [3, 4, 6, 5, 2]
But it is giving = [3, 4, 6, 5, 1, 2]