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

An easy quiz question!

Great work! OK, you're doing great so I'll keep increasing the difficulty. For this step, make another new function named courses that will, again, take the dictionary of teachers and courses. courses, though, should return a single list of all of the available courses in the dictionary. No teachers, just course names! I get an error" Did you return list of lists?" I understand the error. Please help in making a simple and clean list with no lists in it! Thanks!

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(a):
    teachers=0
    for b in a:
        teachers=teachers + 1
    return teachers
def num_courses(c):
    courses=0
    for num_courses in c.values():
        courses= courses + len(num_courses)
    return courses
def courses(d):
    course=[]
    for e in d.values():
        course.append(e)

    return course

1 Answer

Josue Ipina
Josue Ipina
19,212 Points

Try using extend instead of append.