Python Python Collections Sets Set Math

David Chacón
David Chacón
1,071 Points

Sets baby Sets.py

Hey guys,

This one is really confusing me. I've included two different sets of code I believe are either close or should work. They don't though... so... a little push in the right direction would be great!! Thanks!

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(subject):
    subjectList = []
    for keys, values in COURSES.items():
        if subject.intersection(values)
            subjectList.append(keys)

    return subjecList

#or

def covers(subject):
    subjectList = []
    for keys in COURSES.items():
        for values in COURSES[i]:
            if subject.intersection(COURSES[i])
                subjectList.append(keys)

    return subjecList

1 Answer

Jason Anello
MOD
Jason Anello
Treehouse Moderator 94,298 Points

Hi David,

Your first solution is correct with the exception of a syntax error and typo.

Your if statement needs a colon at the end.

In your return statement, you were missing the 't' in subjectList.

David Chacón
David Chacón
1,071 Points

GAH! I was soooo close! Thanks Jason!