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 trialangel moreta
2,912 PointsWhat I'm doing wrong here ?
I run the code on my terminal and i get the right answer which is ["python basic","java basics","php basics","ruby basics"] then i copy/paste my code to the challenge environment and i get a bummer. Why???
this challenge is super confusing. I dont quite understand what they want me to do.
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(set_of_topics):
list_of_courses=[]
for key,value in COURSES.items():#key a str, value a set
if value & set_of_topics[key]:
list_of_courses.append(key)
return list_of_courses
1 Answer
Mckenzie Hessel
Full Stack JavaScript Techdegree Graduate 20,437 Points["python basic","java basics","php basics","ruby basics"] is not necessarily the correct answer. Notice that in the example they enter covers({"Python"}) and the code only returns one course, ["Python Basics"].
They only want your code to return the courses that contain whatever set of topics the computer enters. So if the computer testing your code enters covers({"Ruby"}) then ["Ruby Basics"] should be returned. If the computer enters covers({"input"}) then ["Python Basics", "Java Basics", "Ruby Basics"] should appear, because "input" is contained in those three courses. If covers({"strings"}) is input, then your answer (["python basic","java basics","php basics","ruby basics"]) would be correct because the topic "strings" appears in all four courses
angel moreta
2,912 Pointsangel moreta
2,912 Pointsthank you so much for your valuable time, I could get through challenge.
Mckenzie Hessel
Full Stack JavaScript Techdegree Graduate 20,437 PointsMckenzie Hessel
Full Stack JavaScript Techdegree Graduate 20,437 PointsYou're very welcome!