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 trialMathew Yangang
4,433 Pointssets
I don't know why my code will not pass, i keep getting try again messages
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_all(single_set):
result = []
single_set = list(single_set)
for key,value in COURSES.items():
if single_set.intersection(value):
result.append(key)
return result
def covers(set_topics):
result = []
for x,y in COURSES.items():
if set_topics.intersection(y):
result.append(x)
return result
1 Answer
Kent Åsvang
18,823 PointsI don't have access to the challenge so I don't know what you are trying to do, but you should keep in mind that 'COURSES' is a dictionary, and does not have a intersection()-function. So you should probably turn 'COURSES' into a set() within you function
def covers_all(single_set):
single_set = set(single_set)
....
....
return result