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 trialIan Maina
4,571 PointsWhy is it telling me that it can't find covers?
This code works in workspaces but in the challenge its telling me that it can't find the covers function. what am I doing wrong
def covers(topic_sets):
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"}
}
course = []
for key, val in COURSES.items():
for each in topic_sets:
if each in val:
course.append(key)
return course
1 Answer
Chris Freeman
Treehouse Moderator 68,441 PointsThe given COURSE
dictionary should be left outside of the function covers
.
move the function declaration line below the COURSES
dict and it passes Task 1.
Post back if you need more help. Good Luck!!
Ismail KOÇ
1,748 PointsIsmail KOÇ
1,748 PointsCOURSES must be out of function and function can take single argument (input value), at this (first code in my comment) we have single argument and we do not need for loop, you need to compare value of lists for intersection
if you need help for second step, check this link (can you upvote my comment?)