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 trialDuyen Huynh Ngoc Phuong
3,494 PointsCan you help me to figure what is wrong with my code. I cannot pass the challenge.
create something a bit more refined. Create a new function named covers_all that takes a single set as an argument. Return the names of all of the courses, in a list, where all of the topics in the supplied set are covered. For example, covers_all({"conditions", "input"}) would return ["Python Basics", "Ruby Basics"]. Java Basics and PHP Basics would be exclude because they don't include both of those topics.
def covers_all(single_set):
new_list = []
for key, value in COURSES.items():
if (single_set & value)==single_set:
new_list.append(key)
return new_list
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 B-asics": {"PHP", "variables", "conditions",
"integers", "floats", "strings",
"booleans", "HTML"},
"Ruby Basics": {"Ruby", "strings", "floats",
"integers", "conditions",
"functions", "input"}
}
def covers_all(single_set):
new_list = []
for key, value in COURSES.items():
if (single_set & value)==single_set:
new_list.append(key)
return new_list
def covers(arg):
hold = []
for key, value in COURSES.items():
if value & arg:
hold.append(key)
return hold
2 Answers
Don Newcomb
4,755 PointsI looked at your problem and tried to pass it, but it would not pass do to the "-" you placed here "PHP B-asics": just change that to "PHP Basics": and it should work fine. that was the only thing I found wrong :)
Steven Parker
231,236 PointsYou solution looks good. So I pasted it directly into the challenge and it passed. Does it not pass for you?
Duyen Huynh Ngoc Phuong
3,494 PointsYes, I tried it many times, the first challenge passed, but the second one did not.
Duyen Huynh Ngoc Phuong
3,494 PointsI have tried to log out of my account and logged in again. Luckily the solution is passed this time. Thank you
Steven Parker
231,236 PointsDon found it .. a stray character somehow got inserted into the supplied data.
Steven Parker
231,236 PointsSteven Parker
231,236 PointsGood catch! I didn't even think that the provided data might have been changed. I only pasted in the code portion.