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

Lindsay Barrett
seal-mask
.a{fill-rule:evenodd;}techdegree
Lindsay Barrett
Python Web Development Techdegree Student 7,357 Points

Need help with this question

I am not able to solve this problem. Guidance would be appreciated!

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(topics):
    list = []
    for course in COURSES:
        if topics & COURSES[course]:
            list.append(course)
    return list 


def covers_all(args):
    new_list[]
    for key, value in COURSES.items:
        if args & COURSES[key] ==args:
            new_list.append(key)
    return new_list

2 Answers

Steven Parker
Steven Parker
231,275 Points

You're really close, but I see two issues:

  • the intialization of "new_list" is missing the operator ("=")
  • the invocation of "COURSES.items()" is missing the parentheses
Lindsay Barrett
seal-mask
.a{fill-rule:evenodd;}techdegree
Lindsay Barrett
Python Web Development Techdegree Student 7,357 Points

Thank you that worked!

def covers_all(args):
    new_list=[]
    for key, value in COURSES.items():
        if args & COURSES[key] ==args:
            new_list.append(key)
    return new_list
Steven Parker
Steven Parker
231,275 Points

Lindsay Barrett — Glad to help. You can mark a question solved by choosing a "best answer".

And for fun and extra practice give Advent of Code a try.

Happy holidays! :christmas_tree: