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

Daniel Cunningham
Daniel Cunningham
21,109 Points

Challenge 2/2: Error "Couldnt Find 'Covers'".

Code otherwise seems to work in workspaces. Anyone see the issue? Thank you!

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(param):
    list = []
    for a in COURSES:
        if len(param.intersection(COURSES[a])) >=1:
            list.append(a)
    return list

def covers_all(set):
    list = []
    checkcase = len(set)
    for a in COURSES:
        if len(param.intersection(COURSES[a])) == checkcase:
            list.append(a)
    return list
Daniel Cunningham
Daniel Cunningham
21,109 Points

Great Catch! That worked, thank you very much! I wish they would print the output or error when the task fails so it's easier to catch syntax issues... Thanks again!

I copy paste my challenges over into an IDE and it catches Syntax. I've used a few different ones including PyCharm, Atom, Spyder and VS Code. My current favorite is PyCharm.

Ismail KOÇ
Ismail KOÇ
1,748 Points
def covers_all(arg):
    courses_arg = []
    for course in set(COURSES.keys()):
        if len(arg & COURSES[course]) == len(arg):
            courses_arg.append(course)
    return courses_arg

You can check this out and see what is wrong.

1 Answer

Take a look closely at your second function covers_all(). You are applying .intersection() method against param. However, you did not pass param to the function. Also notice set is in red it is a Python function so I would not name my argument set.

changed comment to answer

Daniel Cunningham
Daniel Cunningham
21,109 Points

Thanks again for your help and the IDE recommendations! Best of luck to you!