1# Creating an empty dictionary
2myDict = {}
3
4# Adding list as value
5myDict["key1"] = [1, 2]
6
7# creating a list
8lst = ['Geeks', 'For', 'Geeks']
9
10# Adding this list as sublist in myDict
11myDict["key1"].append(lst)
12
13# Print Dictionary
14print(myDict)
1import collections
2
3a_dict = collections.defaultdict(list) # a dictionary key --> list (of any stuff)
4a_dict["a"].append("hello")
5
6print(a_dict)
7>>> defaultdict(<class 'list'>, {'a': ['hello']})
8
9a_dict["a"].append("kite")
10
11print(a_dict)
12>>> defaultdict(<class 'list'>, {'a': ['hello', 'kite']})