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

Diego Salas Polar
Diego Salas Polar
21,431 Points

Please help me with this.

I am getting this error, 'Oops! It looks like Task 3 is no longer passing.' for the past two hour. I need help.

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(string):
    return len(string)


def num_courses(teacher):           
    total = 0
    for value in teacher.values():
        for val in value:
            total += 1
    return total

def most_courses(dict):
    max_classes = 0
    for teacher in dict:
        classes = len(dict[teacher])
        if(classes>max_classes):
            max_classes = classes
        most_classes = teacher

    return most_classes

2 Answers

It looks like you finished task 3 and at a later step removed the courses function. If you reimplement it like you had before, you should be back on track

james south
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
james south
Front End Web Development Techdegree Graduate 33,271 Points

this line

most_classes = teacher

needs to be tabbed over once so it's in the if block, not under it. when it's under the if, most_classes will just be set to the last teacher in the loop through the dict keys, not necessarily the teacher with the most classes.