$ ./guess_the_languageProblem Solving — predict the output
Problem Solving — predict the output · medium · #246

What is the output?

d = {'a': 1, 'b': 2}
del d['a']
d['a'] = 3
print(list(d))
  1. ['b', 'a']
  2. ['a', 'b']
  3. ['b']
  4. ['a', 'b', 'a']
Dicts keep insertion order. Deleting 'a' and adding it again inserts it as a new key at the end.
Play Problem Solving ▸