QuestenaPractice that shows what to review next
Question 44

A program runs `data = dict(a=1, b=2)` and then assigns 3 to the existing key `a`. What does `list(data.items())` return?

  1. `[("a", 1), ("b", 2), ("a", 3)]`
  2. `[("a", 1), ("b", 2)]`
  3. `[("b", 2), ("a", 3)]`
  4. `[("a", 3), ("b", 2)]`Correct answer

Explanation

Updating an existing key replaces its mapped value while retaining that key's original insertion position. Moving `a` after `b` would incorrectly treat an update as deletion followed by fresh insertion.

Continue with this test

Start practice
Question 44: A program runs `data = dict(a=1, b=2)` and then assigns 3… · Python Fundamentals · Questena