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) Sets Set Math

Amber Readmond
Amber Readmond
7,861 Points

I feel like I'm completely lost.

Is there anything about my code that even touches on going in the right direction? I wish there were videos explaining answers to code challenges. :'(

sets.py
COURSES = {
    "Python Basics": {"Python", "functions", "variables",
                      "booleans", "integers", "floats",
                      "arrays", "strings", "exceptions",
                      "conditions", "input", "loops"},
    "Java Basics": {"Java", "strings", "variables",
                    "input", "exceptions", "integers",
                    "booleans", "loops"},
    "PHP Basics": {"PHP", "variables", "conditions",
                   "integers", "floats", "strings",
                   "booleans", "HTML"},
    "Ruby Basics": {"Ruby", "strings", "floats",
                    "integers", "conditions",
                    "functions", "input"}
}

def covers({dict_of_courses}):
    list_of_courses = []
    for course in dict_of_courses:
        for value in course:
            if "Python" in value:
                list_of_courses += value
    return list_of_courses            

1 Answer

Steven Parker
Steven Parker
231,269 Points

It looks like you have the right idea, but the argument is going to be a set, not a dictionary. And either way, you wouldn't put braces around the argument name in the definition.

Also, "Python" was shown as an example, but the function shouldn't test for it explicitly.

And you can avoid a nested loop if you check for overlap using one of the set functions discussed in the last video.