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 trialHasan Ahmad
6,727 PointsPython math sets; Task 1 is no longer passing
I have hit another brick wall I guess... I have got this answer from another student but never really understood the concepts behind the code. One of the answers said that to use issuperset() method instead of intersection() method. I did as the answer said but now all it says is that task 1 is no longer passing!
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(single_parameter):
empty_list = []
for keys, values in COURSES.items():
if single_parameter.union(values):
empty_list.append(keys)
return empty_list
def covers_all(single_parameter):
new_empty_list = []
for keys, values in COURSES.items():
if single_parameter.issuperset(values):
new_empty_list.append(keys)
return new_empty_list
2 Answers
Christopher Shaw
Python Web Development Techdegree Graduate 58,248 PointsFor Task 1 to pass, for the intersection of the two sets should be if single_parameter.intersection(values): not union that you have.
You will still need to work on your function covers_all
Michael Neimat
2,680 Pointstry using difference instead of issuperset and look for an empty set as your result
Hasan Ahmad
6,727 PointsHasan Ahmad
6,727 PointsNow it says that it didn't get the right output from covers_all