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!

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

Chaltu Oli
Chaltu Oli
4,915 Points

I don't understand why it's not working?

I don't understand why it's not working?

    "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(topics):
    temp = []
    for topic in COURSES:
        if topics in topic:
    return temp

1 Answer

David Grimm
David Grimm
12,532 Points

First, I think that you expect a String to be passed as a parameter for the function, not a Set as is required in the task. So you'll probably have to iterate over the Set items too.

Second, let's go through your solution: for each course (Python Basics, Java Basics, PHP Basics, Ruby Basics) you check if the provided String is present so if you call it probably like "covers('Java')" you will only search in Course names, not Course topics.

The solution should probably be (in pseudo):

  • For each topic in the parameter Set
  • For each Course
  • Look if the topic is present in the Course.Topics
  • If so, Add it to the List
  • Return the List