I am trying to create an automated python procedure that uses two separate lists to create a dictionary, and so far I am failing. I have two sorted lists, where the nth element in the first list corresponds to the nth element in the second list, and I want to combine them into a dictionary.
For example, a subset of 2 lists is as follows:
name = ['Adam', 'Alfred', 'Amy', 'Andy', 'Bob']
year = [1972, 1968, 1985, 1991, 1989]
I want my output to be:
birth_years = {'Adam':1972, 'Alfred':1968, 'Amy':1985, 'Andy':1991, 'Bob':1989}
I tried to do this with a for loop, but I could not get it to work. I appreciate any help.
source
share