Question
What is the output of the following snippet of code?total={}def insert(items):Â Â if items in total:Â Â Â Â total[items] += 1Â Â else:Â Â Â Â total[items] = 1insert('Apple')insert('Ball')insert('Apple')print (len(total))
Answer: Option C
Was this answer helpful ?
The insert() function counts the number of occurrences of the item being inserted into the dictionary. There are only 2 keys present since the key 'Apple' is repeated. Thus, the length of the dictionary is 2.
Was this answer helpful ?
Submit Solution