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 trialSohail Mirza
Python Web Development Techdegree Student 5,158 PointsI dont understand this challenge
could someone explain what the challenge is asking me to do. Could you break this down step by step what the challenge is asking
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(x):
courses_list = []
for course in COURSES:
if x.intersection(COURSES[course]):
courses_list.append(course)
return courses_list
1 Answer
Josue Ramirez
6,790 PointsFor task 1 you need to create a function that checks for any overlap between the supplied SET and the COURSES SET. In other words, you are looking if these sets have any elements in common. Then for the 2nd task, a subset is where one set contains all of the elements of the other set. This code might help:
def covers_all(topics):
courses_list = []
for course, values in COURSES.items():
if(values & topics) == topics:
courses_list.append(course)
return courses_list
Sohail Mirza
Python Web Development Techdegree Student 5,158 PointsSohail Mirza
Python Web Development Techdegree Student 5,158 PointsHi Josue
Thanks for your reply. I still dont understand what this challenge is asking me. So as it stands we have a Dictionary with keys which are the courses ie Phython basic , java basic and so on.....Within these courses we have the VALUES the topics. Some topic are are the same in the respective courses.
What do you mean by the following that checks for any overlap between the supplied SET and the COURSES SET. In other words, you are looking if these sets have any elements in common.
could you provide an example (not the code) if i input something what can i expect the output to be
I hope that makes sense
Thanks in advance