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 Python Collections (2016, retired 2019) Sets Set Math

Hasan Ahmad
Hasan Ahmad
6,726 Points

Python math sets; Task 1 is no longer passing

I have hit another brick wall I guess... I have got this answer from another student but never really understood the concepts behind the code. One of the answers said that to use issuperset() method instead of intersection() method. I did as the answer said but now all it says is that task 1 is no longer passing!

    "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(single_parameter):
    empty_list = []
    for keys, values in COURSES.items():
        if single_parameter.union(values):
    return empty_list

def covers_all(single_parameter):
    new_empty_list = []
    for keys, values in COURSES.items():
        if single_parameter.issuperset(values):
    return new_empty_list

2 Answers

Christopher Shaw
.a{fill-rule:evenodd;}techdegree seal-36
Christopher Shaw
Python Web Development Techdegree Graduate 58,236 Points

For Task 1 to pass, for the intersection of the two sets should be if single_parameter.intersection(values): not union that you have.

You will still need to work on your function covers_all

Hasan Ahmad
Hasan Ahmad
6,726 Points

Now it says that it didn't get the right output from covers_all

Michael Neimat
Michael Neimat
2,680 Points

try using difference instead of issuperset and look for an empty set as your result