Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Python Collections (Retired) Dictionaries Teacher Stats

unorderable types: list() > int() Why? My code runs in Workspaces

I know there are better ways to do it. But why does my way work in the work spaces. But not in the webpage of treehouse?

In my workspace code I added my own dictionary


t_dict = {'teacher1': 5 , 'teacher2': 2, 'teacher3': 3, 'teacher4': 2, 'teacher5': 6 }


And it returns the name teacher 5 100% of the time without throwing the error: Bummer! unorderable types: list() > int().

teachers.py
def most_classes(t_dict):
    max_value = -1
    for teacher_name in t_dict:
        if t_dict[teacher_name] > max_value:        
            max_value = t_dict[teacher_name]
    for teacher_name in t_dict:
        if t_dict[teacher_name] == max_value:
            max_value = teacher_name
    return max_value

# In the last for-loop i reassign max_value to the dictionary key, so i can return the name of the teacher with the most classes

2 Answers

Kenneth Love
STAFF
Kenneth Love
Treehouse Guest Teacher

Yours doesn't fail because you're using numbers as your dictionary values but the actual test, as explained in the commented text at the top, uses lists as the dict values.

Oh alright awesome, Wow got a response from the teacher/staff. Go teamtreehouse lol