I am making a Gui app in python where i was using a simple snippet. i cannot understand why this happened. The Code:
k = ["Saikat","Ananya"]
names = ["Saikat","Ananya","Sam"]
for i in range (0,len(k)):
if k[i] in names:
names.pop(i)
print(names)
Here Finally the name array consited of "Ananya" instead of what it should have "Sam". I couldn't figure out what is going wrong here.
Thank you all your answer guys, but here is the real problem i am facing. I tried to minimize the code, but the problem i am facing in relaity dosen't got solved by these solutions.
app_list = [["saikat","male"],["ananya","female"],["sam","male"],["joe","male"]]
k= ["Sam","joe"]
for i in (app_list):
print(i[0])
if i[0] in k:
app_list.remove(i)
now it does delete "sam" but it dosen't delete "joe".