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

Vuk Spasojevic
Vuk Spasojevic
9,491 Points

What I am doing wrong. Please help

Code returns list of all courses but check return Bummer Couldn't find 'courses'. Yet function is named courses as requested

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(dict):
    num_teachers = 0
    for teacher in dict:
        num_teachers += 1
    return num_teachers

def num_courses(dict):
    num_courses = 0
    for teacher in dict:
        num_courses += len(dict[teacher])
    return num_courses

def courses(dict):
    courses_list = []
    for teacher in dict:
        for course in dict[teacher]:
                courses_list.append(course)
    return course_list

Hi there,

It'll say "couldn't find 'courses'" if the code won't run due to a syntax error.

I'll have a look and see what I can help you with.

Steve.

I'm still super new at this, but should return course_list be return courses_list?

2 Answers

Your list name is "courses_list" but you're returning "course_list" without an s on courses.

Good spot! :+1: :smile:

Vuk Spasojevic
Vuk Spasojevic
9,491 Points

And officially I am super idiot. Thank you all for help.