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 trial
Omar G.
3,620 Pointscovers_all task 2 of 2
Hello , I am having trouble passing this challenge. this is my code so far
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(topics):
final_list = []
for course_name, course_topic in COURSES.items():
if course_topic.intersection(topics):
final_list.append(course_name)
return final_list
def covers_all(course):
course_list = []
for course_name, course_topic in COURSES.items():
if course_topic.intersection(course):
course_list.append(course_name)
return course_list
My logic is to create an empty list. Then go through the dictionary in a loop and basically check if the value is in the function. if it is then append it to the empty list. I know I am missing a step so if anyone can help me that would be great
2 Answers
Ivan Kazakov
Courses Plus Student 43,317 PointsHey Omar,
you need to check if your course_name's set of topics is a superset to your course parameter (which is a list of topics):
...
if course_topic >= course:
...
Omar G.
3,620 PointsHello Ivan,
Thank you for the help and for the link. I understand it better now. I really appreciate you taking the time to reply!😄