Please forgive me for asking, but despite a ton of dictionary.update threads I could not find one that is an example of what I'm want to do.
I have a dictionary:
dictionary = {1:'a', 2:'b', 3:'c', 4:'d'}
and I have a list:
zip_codes = [25840, 26807, 24739, 26501]
I want to add each list item to the dictionary values. The result would look like:
dictionary = {1:('a', 25840), 2:('b', 26807), 3:('c', 24739), 4:('d', 26501)}
The best result I've got is from trying something like this:
for i in zip_codes:
new_list = [(key,value, i) for key, value in dictionary.items()]
print(new_list)
But this returns the following:
[(1, 'a', 26501), (2, 'b', 26501), (3, 'c', 26501), (4, 'd', 26501)]
Because I am looping through the list items, I get the last list item (26501) as the result. I'm stumped.