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 trialDavid Chacón
1,086 PointsSets by the Beach...part 2
Hey Community!
I feel like I have a question on every challenge! This on I'm just not sure how to take a set as an input. The rest I think is close. Any pointers?
Thanks!
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(subject):
subjectList = []
for keys, values in COURSES.items():
if subject.intersection(values):
subjectList.append(keys)
return subjectList
def covers_all({item1, item2}):
subjectsList = []
set1 = {item1, item2}
for keys, values in COURSES.items():
if set1.intersection(values):
subjectsList.append(keys)
return subjectsList
Chris Freeman
Treehouse Moderator 68,441 PointsSorry for the slow response. We are all fellow students answering questions. Some questions get missed and fall to later pages. See answer below.
1 Answer
Chris Freeman
Treehouse Moderator 68,441 PointsYou are not far off the answer. The function should take a single argument that will be a set.
use set1
as the parameter, and remove the assignment to set1
inside the function.
This function is looking for a more precise comparison than a simple intersection. It is looking to see if set1
is a proper subset of `values.
use issubset
instead of intersection
Post back if you need more help. Good luck!!
David Chacón
1,086 PointsDavid Chacón
1,086 PointsAnything from anyone? Seems like a long time to go without a response at all, especially for a paid service.