N Ngoc Hue New member Sep 20, 2021 #1 What will be the output of the following Python code? Code: >>> import collections >>> b=dict() >>> b=collections.defaultdict(lambda: 7) >>> b[4] A. 4 B. 0 C. An exception is thrown D. 7
What will be the output of the following Python code? Code: >>> import collections >>> b=dict() >>> b=collections.defaultdict(lambda: 7) >>> b[4] A. 4 B. 0 C. An exception is thrown D. 7
D Danh Trịnh New member Sep 20, 2021 #2 Answer: d Explanation: The statement a=collections.defaultdict(lambda: x) gives the default value of x even if the keys don’t exist in the dictionary. Upvote 0 Downvote
Answer: d Explanation: The statement a=collections.defaultdict(lambda: x) gives the default value of x even if the keys don’t exist in the dictionary.