I have a list string_array = ['1', '2', '3', '4', '5', '6']
and a list of lists
multi_list = [['1', '2'], ['2', '3'], ['2', '4'], ['4', '5'], ['5', '6']]
The first element of each sub-list in multi_list
will have an associated entry in string_array
.
(Sublists will not have duplicate elements)
How do I map these associated elements into a dictionary like:
{
'1': ['2'],
'2': ['3', '4'],
'3': [],
'4': ['5'],
'5': ['6'],
'6': []
}
See Question&Answers more detail:os