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

Brent Liang
PLUS
Brent Liang
Courses Plus Student 2,944 Points

Task 1 no longer passing

The three previous paragraphs are all correct.

The objective for task 4, which I attempted in the last block of code, is to extract all classes taught by teachers into a single list.

With this code below it keeps saying that task 1 is no longer passing, what's the problem?

teachers.py
# The dictionary will be something like:
# {'Jason Seifer': ['Ruby Foundations', 'Ruby on Rails Forms', 'Technology Foundations'],
#  'Kenneth Love': ['Python Basics', 'Python Collections']}
#
# Often, it's a good idea to hold onto a max_count variable.
# Update it when you find a teacher with more classes than
# the current count. Better hold onto the teacher name somewhere
# too!
#
# Your code goes below here.
def most_classes (dicts):
    max_count = 0
    for dicta in dicts:
        count = len(dicts[dicta])
        if count > max_count:
            max_count = count
            name = dicta
    return name 

def num_teachers (dicts):
    num = 0
    for dicta in dicts:
        num += 1
    return num

def stats (dicts):
    result_list = []
    for dicta in dicts:
        teacher_name = dicta
        teacher_class = len(dicts[dicta])
        result_list.append([teacher_name,teacher_class])
    return result_list 

def courses (dicts):
    hey_list = []
    for dicta in dicts:
        for item in dicts[dicta]:
        hey_list.append(item)
    return hey_list
Steven Parker
Steven Parker
229,670 Points

:mailbox: Got your message, looks like "GoogleSearch" beat me here.

1 Answer

Name:GoogleSearch orJonathan Sum
Name:GoogleSearch orJonathan Sum
5,039 Points

You need a indented block at the last two lines. Do u see the for statment? At the next line of for statment, u need a indented block.