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

Return single list of values from dictionary.

Grrrrrrr. Not entirely sure why this is not working. I've tried multiple code variations, too. Please do not just post the answer but an explanation as well. i thought this was looping through the values in the dictionary and adding them to a new list?

# 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.
def num_teachers(teachers):
    count = 0
    for teacher in teachers:
        count += 1
    return count

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

def courses(d):
    course = []
    for e in d.values():

    return course

3 Answers

Grigorij Schleifer
Grigorij Schleifer
10,365 Points

Hi Christopher, you are doing great. BUT, the challenge asks you to return a single list. The append method will append every LIST corresponding to a key value. So you will have multiple lists inside course and not a single list with all courses ...

What method does concatenate values instead of appending them?

Here a nice link that could be helpful.

I hope that helps :sunglasses:

Awesome link for sure, thank you very much, I'm running into a problem when I replace the append with extend. My PyCharm says "course not defined", Ughh. It also will still not pass the quiz. This question is frustrating me quite a bit!

Grigorij Schleifer
Grigorij Schleifer
10,365 Points

Hey Christopher, it is absolutely normal to feel overwhelmed and frustrated. Coding is hard and it requires a lot of work. But if you look back you will see how much you have learned already ... and if you continue on working hard ... you will get better and better ...

Watch this video, it is very motivating

Back to the question. Have you deleted the line between the methods body and the return statement?

Let me know if you need more help.

The most annoying thing about coding is that the simplest thing throws everything off. I thought I had tried that already but it did the trick right way. Ugh!

Thanks for all the help!

Grigorij Schleifer
Grigorij Schleifer
10,365 Points

Man, you are doing good. Believe me! I struggle all the time and have almost no time to code. This is the most frustrating part. Coding is learning a language like Chinese or Russian ... both are very hard and beautiful languages ... It is hard to see progress, but you will ... it will take you years to get good at it, the way is the journey, not the destination ...

Keep pushing