python - Collections.defaultdict difference with normal dict - Stack
https://stackoverflow.com/questions/5900578/collections-defaultdict-difference-with-normal-dict
Webimport collections d = collections.defaultdict(int) for i in range(10): d[i] += i print(d) # Output: defaultdict(<class 'int'>, {0: 0, 1: 1, 2: 2, 3: 3, 4: 4, 5: 5, 6: 6, 7: 7, 8: 8, 9: 9}) import collections d = {} for i in range(10): d[i] += i print(d) # Output: Traceback (most recent call last): File "python", line 4, in <module> KeyError: 0
DA: 96 PA: 7 MOZ Rank: 86