Assuming you want your dictionary key to be the 1st element of the list, here is an implementation:
list = [[1, 30, 5], [2, 64, 4]]
dict = {}
for l2 in list:
dict[l2[0]] = l2[1:]
It works by iterating through list
, and the sub-list l2
. Then, I take the 1st element of l2
and assign it as a key to dict
, and then take the rest of the elements of l2
and put it as the value.
The result is the finished dictionary {1: [30, 5], 2: [64, 4]}