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 trialTerry Felder
1,738 Pointsmy function returns the right answers, why won't it pass the challenge?
i've tried a couple different methods, like converting the argument into a set by dong this:
a_set = {a_set}
but then if you pass in an actual set into the function and error shows up...
what to do...what to do?
i want a function that takes 1 set a paramater, and returns a list of courses whose values overlap with the given set parameter.
so first i created an empty list. then my next step was to go through each course now while looping through the course i want to check to see if the set of values of that course match with the given set. if it is a match add that course to my overlapping_course list. once the loop is complete show me the list
after checking my work i get bummer try again..
so it makes sense to me what am i missing? im excited i got this far by myself excitied to hear answers thank you very much!
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(a_set):
overlapping_courses = []
for x in COURSES:
if a_set.intersection(COURSES[x]):
overlapping_courses.append(x)
return overlapping_courses
2 Answers
Steven Parker
231,236 PointsYour code looks good to me.
So I tested it by pasting it directly into the challenge, and it passed task 1!
I've heard sometimes you need to restart the browser, give that a try.
Terry Felder
1,738 PointsThank you Steven!