I want to create a dictionary with multiple values in the form of a list for value of a key(To be precise for key '0').But when I use the zip function it is only giving the last updated value for that key instead of all values attached to that key. Below is the code.
values_list = [[0, 0], [0, 1], [0, 2], [1, 0], [1, 1], [1, 2], [2, 0], [2, 1], [2, 2]]
keys_list = [0,0,0,1,0,0,2,-1,0]
my_dict = dict(zip(keys_list, values_list))
print(my_dict)
Output from above code:
{0: [2, 2], 1: [1, 0], 2: [2, 0], -1: [2, 1]}
Required Output:
{0: [[0, 0],[0, 1],[0, 2],[1, 1],[1, 2],[2, 2]], 1: [1, 0], 2: [2, 0], -1: [2, 1]}