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

Can't figure out step five

Can someone give me some direction??

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(arg):
    count = 0 
    for item in arg.keys():
        count += 1
    return count

def num_courses(arg):
    count = 0
    for course in arg.values():
        for i in course:
            count += 1
    return count

def courses(arg):
    course_list = []
    for course in arg.values():
        for i in course:
            course_list.append(i)
    return course_list

def most_courses(arg):
    max_count = 0
    for teacher in arg:
        count = 0
        for course in teacher:
            count += 1
        if count > max_count:
            max_teacher = teacher
            count = max_count
    return teacher

def stats(arg):
    teacher_list = []
    return teacher_list

1 Answer

Steven Parker
Steven Parker
231,269 Points

You've already done everything needed in the other steps, you just need to organize things a bit differently. You'll still want to loop through the dictionary items, but this time you'll make a list with the name and count in it, and then add that small list as an item to the big list.