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 trialjohn larson
16,594 Pointsreturn a list of courses from COURSES where the supplied set and the course's value (also a set) overlap.
I've tested this several different ways and it seems to work, but it fails the challenge. Not looking for a solution, just a clue as to what I am missing.
def covers(topics): # topics = type set
list_of_courses = [] # the key for topics that overlap
# compare topics w/ dct value
# if topics and value overlap
# append key to list_of_courses
for key, value in COURSES.items():
if value.intersection(set_of_topics):
list_of_courses.append(key)
return list_of_courses
1 Answer
Jason Anello
Courses Plus Student 94,610 PointsHi John,
It's hard to give a hint on this without giving away the solution because you're so close.
Take a look at the names of your variables. topics
is the parameter to your function. Where are you using that in your code?
john larson
16,594 PointsThanks Jason. I fixed that, now I have:
def covers(topics): # topics = type set
list_of_courses = [] # the key for topics that overlap
# compare topics w/ dct value
# if topics and value overlap
# append key to list_of_courses
for key, value in COURSES.items():
if value.intersection(topics):
list_of_courses.append(key)
But it's still not passing. Any other clues?
Jason Anello
Courses Plus Student 94,610 PointsYou're missing the return statement that you had originally.
This new code passes once I add that in.
john larson
16,594 Pointsjohn larson
16,594 PointsThanks you Jason, I appreciate your help.