Do you know why 14/19 works the way it does? +right code


Hi! With use of help from community I made the right answer to 14/19 part, but I still don't understand why? I was trying different versions and one ended up working but even though it passed I don't feel like I understood more and have that skill for following tasks. I would really apprieciated if someone coudl tell me why this code:

d = {'a': 'apple', 'b': 'berry', 'c': 'cherry'}

for key in d:
    # Your code here!
    print key, d[key]

Prints out such results:

a apple
c cherry
b berry

I really don't get why I didn't print the sting as it was (so a, then b, then c) but instead changed (so a, then c, then b).


A dictionary does not store order, only key-value pairs. When we open a carton of eggs, we do not know which came out of the chicken first. And, we can take them out of the carton in any order.


How does printing the key via print key, print the key then following that you specify the key within d via d[key] print the value?