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 Functional Python The Lambda Lambada Recursion

Andy McDonald
Andy McDonald
Python Development Techdegree Student 6,418 Points

Calling the function within the function

This part is really hard for me to conceptualize, to run the function again an return new values. I figure I have to call it based upon the values I got on the first time around but I'm not sure how to turn the function on those items within the items in the dict. I just really don't know the syntax for doing that.

courses = {'count': 2,
           'title': 'Django Basics',
           'prereqs': [{'count': 3,
                     'title': 'Object-Oriented Python',
                     'prereqs': [{'count': 1,
                               'title': 'Python Collections',
                               'prereqs': [{'count':0,
                                         'title': 'Python Basics',
                                         'prereqs': []}]},
                              {'count': 0,
                               'title': 'Python Basics',
                               'prereqs': []},
                              {'count': 0,
                               'title': 'Setting Up a Local Python Environment',
                               'prereqs': []}]},
                     {'count': 0,
                      'title': 'Flask Basics',
                      'prereqs': []}]}

def prereqs(data, pres=None):
    pres = pres or set()
    for pre in data['prereqs']:
    for i in pres:

    return pres
Chris Freeman
Chris Freeman
Treehouse Moderator 68,029 Points

Check out a previous answer I gave on thinking through the recursion. Let me know if you need further help. Gook luck!!

1 Answer