When i use for function the output is ['Banana', 'Orange']; However, when used if function the output is ['Apple', 'Banana', 'Orange']. Why?
foods = ["Apple", "Banana", "Pineapple", "Orange"]
removeFoods = foods[2]
for removeFoods in foods:
foods.remove(removeFoods)
print(foods)
________
foods = ["Apple", "Banana", "Pineapple", "Orange"]
removeFoods = foods[2]
if removeFoods in foods:
foods.remove(removeFoods)
print(foods)