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

igor corrales
igor corrales
2,474 Points

Iḿ totally lost with this exercise

I don't know how can I get the right key in the dictionary and also combinate with the set......can someone give me a hint ? please

    "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(self):
    for contents in COURSES.values():
        if contents > self:
            return COURSES.keys()

2 Answers

Hint: I would recommend using a loop similar to this:

key_set ={}
for key, value in COURSES.items():
    if logic:
return key_set
Steven Parker
Steven Parker
229,644 Points

You'll probably want a loop so you can compare the argument with each dictionary entry separately. And you could create a new list to add the results to during the loop. After the loop finishes, then you would return the new list.

You also might not want to use "self" as a parameter name, since it is commonly used in class methods to refer to the instance and may be confusing.