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 trialDaniel Deiana
11,341 PointsStruggling to understand question sets.py
Hi I've been staring at this question for half an hour and don't know where to begin. Maybe a couple more examples of inputs to the function and outputs might help? I've been playing with sets in the Powershell to gain some confidence with the methods but I don't think I understand the questions wording and how to apply it. Regards Dan
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(set_of_topics):
1 Answer
Andrew Mlamba
15,642 PointsCheckout this explanation. Hope it helps.
PS:more concrete answers are welcome.
https://teamtreehouse.com/community/setspy-code-challenge-task-1-failing
Daniel Deiana
11,341 PointsDaniel Deiana
11,341 PointsThank you Andrew. Your explanation of the task helped!
def covers(list_of_topics): list = [] for course, course_topics in COURSES.items(): if len(course_topics.intersection(list_of_topics)) > 0: list.append(course) return list