Assign 2D list as keys and another 1D list as values to a dictionary

  arrays, list, python, python-3.x

I need to assign 2 list of different dimensions to a dictionary as Key Value pairs.
(It should also store repeated values as of list2 below)

list1 = [[0, 0, 0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 1, 0, 1, 1], [0, 0, 0, 0, 1, 0, 1, 0], [0, 0, 0, 0, 1, 1, 0, 0]]

list2 = [0, 1, 1, 2]

dict_output = {[0, 0, 0, 0, 0, 1, 0, 0]:0, [0, 0, 0, 0, 1, 0, 1, 1]:1, [0, 0,
0, 0, 1, 0, 1, 0]:1, [0, 0, 0, 0, 1, 1, 0, 0]:2}

I have tried using zip but didn’t worked.

Source: Python Questions

LEAVE A COMMENT