Something of value


#1


https://www.codecademy.com/courses/python-beginner-en-IZ9Ra/1/4?curriculum_id=4f89dab3d788890003000096

I have managed to solve the problem by using the forum, and looking at various methods. What I cannot understand is how does python pair the items? Is it because it pairs up the two items due to their placement in individual lists; so banana is first in both lists, so it pairs them? Or it recognises the name "banana" in each list and pairs them? Hope my question makes sense.


Replace this line with your code. Do not remove the backticks that are above or below this line.


#2

It never pairs them. Lets look at some general dictionary syntax:

first_dictionary = {
  "key1" : "value1",
  "key2" : "value2",
  "key3" : "value3",
  "key4" : "value4",
} 
second_dictionary = {
  "key1" : "value5",
  "key2" : "value6",
  "key3" : "value7",
  "key4" : "value8",
}

now, if i loop over either one of the dictionary's, it doesn't really matter:

for key in first_dictionary:
    print key

this will print the key (key1, key2, key3 and key4), and then i can use the bracket notation to get the value:

for key in first_dictionary:
    print first_dictionary[key]
    print second_dictionary[key]

now, the trick is that both dictionary's have the same key! because both first_dictionary and second_dictionary both have key1, it will print out the values at key1. The whole trick is that the keys are the same, otherwise this won't work