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

Gilang Ilhami
Gilang Ilhami
12,045 Points

Teacher stats

The fourth step

Bummer! You returned 5 courses, you should have returned 18.

Do i have to add something here?

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.

my_dict = {'Gilang' : ['Basic of Nuclear Technologies', 'Practical Quantum Physics', 'The Philosophy of Physics'], 'Yohannes' : ['Energy Engineering', 'Green Technology'], 'Audrey' : ['The Psychology of Patriotism']}

def most_classes(my_dict):
    max_count = 0

    most_class = ""

    for teachers in my_dict:
        if len(my_dict[teachers]) > max_count:
            max_count = len(my_dict[teachers])
            most_class = teachers
    return most_class

def num_teachers(my_dict):
    teacher = len(my_dict.keys())
    return teacher

def stats(my_dict):
    the_list = []

    for teachers in my_dict:
        new_string = [teachers, len(my_dict[teachers])]
        the_list.append(new_string)
    return the_list

def courses(my_dict):
    single = []
    for value in my_dict.values():
        single.append(value)
    return single

1 Answer

Steven Parker
Steven Parker
231,275 Points

:point_right: Perhaps you meant to use extend?

The append method adds a list as a single new element, but extend adds each item from a list as a separate element.