3/18 Output Question


#1

I just have a simple question about the output of this section.
My code is…

my_dict = {“Name”:“Eric”,“Age”:“26”}
for key in my_dict:
print key, my_dict[key]

And this is my output.

Age 26
Name Eric

So my question is why is it printed in this order and not the order that I put in the dictionary?


#2

you used python for this right ?


#3

yes, this is python code

@epicpenner33, because dictionaries are accessed by key, so there is no reason to keep the order. Each data type has its advantages and drawbacks.


#5

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.