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 (2016, retired 2019) Dictionaries Teacher Stats

What im doing wrong here

I tried it in my python IDLE on PC and it's giving me the answer. But here it seas 'Try Again'

teachers.py
# The dictionary will look something like:
# {'Andrew Chalkley': ['jQuery Basics', 'Node.js Basics'],
#  'Kenneth Love': ['Python Basics', 'Python Collections']}
#
# Each key will be a Teacher and the value will be a list of courses.
#
# Your code goes below here.
def num_teachers(dictionary):
    num_teachers = 0
    for name in dictionary.keys():
        num_teachers += 1
    return num_teachers

def num_courses(dictionary):
    num_courses = 0
    for courses in dictionary.values():
        num_courses += len(courses)
    return num_courses 

def courses(dictionary):
    list_courses = []
    for courses in dictionary.values():
        list_courses += courses
    return list_courses

def moust_courses(dictionary):
    # Should return the name with the most courses
    the_name = ""
    num_courses = 0
    for name, courses in dictionary.items():
        if len(courses) > num_courses:
            the_name = name
            num_courses = len(courses)

    return the_name

If I copy paste your code with that change it passes the first 4 tasks. You may need to copy your code and click restart - then paste it back in. Or close/reopen you browser. Sometimes the checker gets hung up.

2 Answers

Thank you very much for the help. I don't know why sumetimes I stumb on such obvious mistakes, I suppose it's a part from the learning. Again thanks allot ;)

You misspelled most here

def moust_courses

Yes i fixed it and still it's not right