Skip to content
Related Articles

Related Articles

Python-Quizzes | Python Dictionary Quiz | Question 25

View Discussion
Improve Article
Save Article
Like Article
  • Difficulty Level : Basic
  • Last Updated : 17 Sep, 2020

Question 25:Find the output of the following program:

counter = {} 
def addToCounter(country): 
    if country in counter: 
        counter[country] += 1
        counter[country] = 1
print (len(counter))

(A) 0
(B) 1
(C) 2
(D) 3

Answer: (D)

Explanation: The task of “len” function is to return the number of keys in a dictionary. Here 3 keys are added to the dictionary “country” using the “addToCounter” function. The keys to a dictionary are case sensitive.

Quiz of this Question

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!