I have four lists:
list_a = ['hello', 'yes', 'you']
list_a_ind = [0, 1, 2]
list_b = ['he', 'here', 'great']
list_b_ind = [1, 2, 3]
I want to create a dictionary with combined index as keys and combined elements as values, result as below:
dictionary_ab = {(0,1): ('hello', 'he'),
(1,2): ('yes', 'here'),
(2,3): ('you', 'great)}
what’s the fastest way to do it?
>Solution :
This snippet will do the trick:
dict(zip(zip(list_a_ind, list_b_ind), zip(list_a, list_b)))