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

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