Can`t understand loops logic


So, this code write to me next string: "apple cherry berry ". 1st is "apple" but why the second, instead of "berry", is "cherry"?

Sorry for my English. :smiley:

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

for key in d:
    # Your code here!
    print "%s " % d[key]


This has nothing to do with the loop logic, dictionary's are unordered, since you access them by key, there is no reason for dictionaries to be ordered


But why second is "cherry"? Im complete that lesson but dont understand why it work like this.


Because dictionaries are unordered. The order in which you put them, doesn't have to be the order in which order python stores the dictionary


Hmm, many thanks to you.