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

I dont understand what is wrong here? It works fine in workspaces

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!

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 courses(arg):
    newlist = []

    for value in arg.values():
        for item in value:
            newlist.append(item)

    return newlist

def num_courses(arg):
    total = 0
      for value in arg.values():
        for item in value:
            total += 1

    return total

def num_teachers(arg):
    keys = 0
    for key in arg.keys():
        keys += 1

    return keys

Anyone?

1 Answer

Chris Freeman
MOD
Chris Freeman
Treehouse Moderator 68,423 Points

Your so close. An indentation error was introduced in function num_courses: the first for loop is indented farther than the total assignment statement above it.

Post back if you need more help. Good luck!!!