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

JAMES CADMAN
JAMES CADMAN
3,312 Points

Why is this not correct?

I don't understand why I'm getting Bummer: Try again! This works perfectly in PyCharm.

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

def num_courses(teachers):
    courses = 0
    for teacher in teachers:
        courses += len(teachers[teacher])

    return courses

def courses(teachers):
    courses = []

    for teacher in teachers:
        for course in teachers[teacher]:
            courses.append(course)

    return courses


def most_courses(teachers):
        courses = 0
        busiestTeacher = ""
        for teacher in teachers:
            if courses < len(teachers[teacher]):
                courses = len(teachers[teacher])
                busiestTeacher = teacher

        return busiestTeacher

1 Answer

Chris Freeman
MOD
Chris Freeman
Treehouse Moderator 68,441 Points

PyCharm may be more forgiving. There is a mix use of spaces and tabs in the indentation of most_courses. Replacing the tabs with spaces allows the code to pass the challenge.

Post back if you need more help. Good luck!!