a_dictionary = {"name" : "John", "age" : 20}
a_list = []
dictionary_copy = a_dictionary.copy()
a_list.append(dictionary_copy)
print(a_list)
import collections
a_dict = collections.defaultdict(list) # a dictionary key --> list (of any stuff)
a_dict["a"].append("hello")
print(a_dict)
>>> defaultdict(<class 'list'>, {'a': ['hello']})
a_dict["a"].append("kite")
print(a_dict)
>>> defaultdict(<class 'list'>, {'a': ['hello', 'kite']})
d = {1:2}
d.update({2: 4})
print(d) # {1: 2, 2: 4}
from collections import defaultdict
dates_dict = defaultdict(list)
for key, date in cur:
dates_dict[key].append(date)
dates_dict.setdefault(key, []).append(date)