Weird Ordering?


#1



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.


#2

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


#3

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


#4

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

for key in l:
    print student[key]

#5

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

students = [lloyd, alice, tyler]

#6

Alright Thank you so much! :slight_smile:


#7

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