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

Marcel Moritz
Marcel Moritz
15,111 Points

Why is my function not passing ?

I can't figure out why it's not passing. If i put in a value it returns me the Course for the value, if different courses have the same value in common in returns me all the courses with that value.

I really have a hard time understanding what i'm doing wrong ?

Marcel

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(arg):
    list = []
    for topics, courses in COURSES.items():
        if arg == courses.intersection(arg):
            list.append(topics)
    return list

1 Answer

Hi Marcel,

You interpreted the task 1 instructions the same way that I did initially. Your code is making sure that the course covers ALL of the topics that are passed in. This is actually what task 2 wants you to do. So the good news is that you already have the code for task 2 but you'll have to change the function name when you get to it.

For this task, you should include the course if it covers at least one of the topics passed in.

For example, if "integers" and "Ruby" are passed in for the topics, the python course should be included because it covers "integers". It doesn't have to cover "Ruby" too.

Marcel Moritz
Marcel Moritz
15,111 Points

Thank you that helped me a lot ! ?