Python-Quizzes | Python Dictionary Quiz | Question 13

Question 13:Find the output of the following program:

filter_none

edit
close

play_arrow

link
brightness_4
code

dictionary1 = {'GFG' : 1
            'Google' : 2
            'GFG' : 3
            
print(dictionary1['GFG']); 

chevron_right


(A) Compilation error due to duplicate keys
(B) Runtime time error due to duplicate keys
(C) 3
(D) 1


Answer: (C)

Explanation: Here, GFG is the duplicate key. Duplicate keys are not allowed in python. If there are same keys in a dictionay, then the value assigned mostly recently is assigned to that key.

Quiz of this Question

My Personal Notes arrow_drop_up
Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.