Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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.