Why is my Python dictionary iteration skipping keys when i modify it inside the loop?

3 days ago 12
ARTICLE AD BOX

I am to update a python dictionary while iterating over it, but some keys are getting skipp

data = { "a": 1, "b": 2, "c": 3, "d": 4 } for key in data: if data[key] % 2 == 0: del data[key] # remove even values print(data)
Read Entire Article