Weird Ordering?


For the Record

It prints the dictionaries out but it does it in a weird way that doesn't make sense

I expected it to print out:name hw quiz tests, but it's
It's quiz test name hw

Replace this line with your code.


Hello @arandium
I think you're trying to say that the information(values) aren't printed in order-ed manner?
In python 2.x Dictionaries are not ordered so its get printed in random manner.

There are few changes in Python 3.x


Ah yes that makes sense!
Is there any way to assert an order on the list or do you have to print each one individually for it to work properly


We can do this..
l = sorted(alice.keys()) # we can define it globally
As all of our dictionary have same keys.

for key in l:
    print student[key]


The students class list was created in the order that they were defined, because we wrote it that way.

students = [lloyd, alice, tyler]


Alright Thank you so much! :slight_smile:


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