Alright I searched, but I did not find an answer to my specific problem. I am creating a dictionary of lists. I have while loop creating a few lists of values as well as a name to associate with it:
dict = {}
list = [1, 2]
name = key1
list = [3, 4]
name = key1
If the name is the same, the list will be appended to the existing set of values for the key. Here is the code I have:
if key in dict:
dict[key].append(list)
else:
dict[key] = list
This is the output I want:
dictionary = {'key1': [1, 2], [3, 4]}
However I keep getting this output:
dictionary = {'key1': [1, 2, [3, 4]]}
where the second list to the key is being put inside of the first list.