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 (Retired) Dictionaries Teacher Stats

I have only 5 total courses in my dictionary why does function not pass and expect a list of 18 courses

My code here

my_dict = {'Jason Seifer': ['Ruby Foundations', 'Ruby on Rails Forms', 'Technology Foundations'],
'Kenneth Love': ['Python Basics', 'Python Collections']}

def courses(my_dict):
    course_list = []
    for courses in my_dict.values():
        course_list.append(list(courses))

    return course_list


courses(my_dict)

Figured it out it used .extend instead of append

def courses(my_dict):
    course_list = []
    for courses in my_dict.values():
        course_list.extend(list(courses))
    return course_list


courses(my_dict)

1 Answer

Kenneth Love
STAFF
Kenneth Love
Treehouse Guest Teacher

Yep, you have to add the content of the new list, not just the new list. Glad you figured it out!