practicepython.in
python exercises
171 exercises

Daily #24 · 22 October 2026

Back of the queue Medium

What does this print?

stock = {"apples": 3, "pears": 5}
del stock["apples"]
stock["apples"] = 4
print(list(stock))
  1. A['pears']
  2. B['pears', 'apples']
  3. C['apples']
  4. D['apples', 'pears']
Show the answer

B: ['pears', 'apples']

Why: Dicts remember insertion order. Deleting a key and adding it again puts it at the end, as a new arrival. Changing the value of an existing key does not move it.

Play today’s puzzle →