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

Set Python

Maybe I don't understand the questions, but here is what I have. When asked to run covers func with covers({"Python}), I get the courses that overlapped, which in this case is just Python Basics. If I pass in something such as booleans, I get all except Ruby Basics in a list. From what the questions stated, it wants a list of courses from courses if the supplied set and course value (which is a set) overlap. What am I missing here?

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(given):
    course_list = []
    for i in courses:
        for n in courses[i]:
            if given & courses[i]:
                if i not in course_list:
                    course_list.append(i)
    return course_liste

1 Answer

Chris Freeman
MOD
Chris Freeman
Treehouse Moderator 68,454 Points

You are very close. The reference dictionary is COURSES not courses.

Also, there's a typo in "course_liste"

That was it! I didn't realize that my IDE had made the COURSES lowercased so it worked on my end there but not on treehouse. Thanks for that!