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 trialAlejandro Byrne
2,562 PointsWhy can't the challenge find my function?
Hi, the error I get when I put my code in is "Couldn't find 'covers'!". Why? And, if you found a way to make that work, could you help me with the rest of the function, I have a few issues...
def covers(course):
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"}
}
output = []
if course in COURSES["Python Basics"].intersection(COURSES["Java Basics"]):
output.append("Java Basics")
if course in COURSES["Python Basics"].intersection(COURSES["PHP Basics"]):
output.append("PHP Basics")
if course in COURSES["Python Basics"].intersection(COURSES["Ruby Basics"]):
output.append("Ruby Basics")
if "Ruby Basics" or "Java Basics" or "PHP Basics" in output:
output.append("Python Basics")
return output
1 Answer
Chris Freeman
Treehouse Moderator 68,441 PointsThe challenge checker can't find the function covers
due to the syntax error in the last if
statement. The or
must be complete statements, such as:
if "Ruby Basics" in output or "Java Basics" in output or "PHP Basics" in output:
With this syntax correct it will run but not provide the correct results. Try running it locally so that you can test the function output.
Tri Pham
18,671 PointsTri Pham
18,671 Pointsyeah the error messages aren't too helpful and theres really no way to figure out what you did wrong. thats why I suggest you use an online ide like this so you can print() out some stuff and see what you are getting.
First, you should probably leave COURSES outside of the function.
More importantly Second, your expected input is not a course but a Set of topics.