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 trialDaniele Santos
16,536 PointsIt runs on my PyCharm but it won't pass the tests on Workspaces. Why?
I don't understand why this is not working. Anyone has a hint?
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(topic):
topic_list = []
for key in COURSES:
if topic.intersection(COURSES[key]):
topic_list.append(key)
return topic_list
2 Answers
Jeff Muday
Treehouse Moderator 28,720 PointsYou are very close to the correct answer. I pasted in your code and changed the indentation a tiny bit. The way you had it, it would work on some tests, but fail on some of the deeper tests run by the code challenge.
Good luck with Python!
def covers(topic):
topic_list = []
for key in COURSES:
if topic.intersection(COURSES[key]):
topic_list.append(key)
return topic_list # fix your indentation here to this.
Daniele Santos
16,536 PointsThanks for taking the time to check my code, Jeff!