QuestenaPractice that shows what to review next
Question 40

A dictionary literal lists the same equal key twice, first with value 1 and later with value 2. Which value is retained for that key?

  1. Both values are retained under duplicate entries.
  2. Value 1 is retained because the earliest entry wins.
  3. Neither value is retained because SyntaxError occurs.
  4. Value 2 is retained because the later entry wins.Correct answer

Explanation

A dictionary has only one entry for a given equal key, and the later value replaces the earlier one while the literal is built. Duplicate equal keys do not coexist and do not cause a syntax failure.

Continue with this test

Start practice
Question 40: A dictionary literal lists the same equal key twice, first… · Python Fundamentals · Questena