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 trialDavid Chac贸n
1,086 PointsSets baby Sets.py
Hey guys,
This one is really confusing me. I've included two different sets of code I believe are either close or should work. They don't though... so... a little push in the right direction would be great!! Thanks!
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(subject):
subjectList = []
for keys, values in COURSES.items():
if subject.intersection(values)
subjectList.append(keys)
return subjecList
#or
def covers(subject):
subjectList = []
for keys in COURSES.items():
for values in COURSES[i]:
if subject.intersection(COURSES[i])
subjectList.append(keys)
return subjecList
1 Answer
Jason Anello
Courses Plus Student 94,610 PointsHi David,
Your first solution is correct with the exception of a syntax error and typo.
Your if
statement needs a colon at the end.
In your return
statement, you were missing the 't' in subjectList
.
David Chac贸n
1,086 PointsDavid Chac贸n
1,086 PointsGAH! I was soooo close! Thanks Jason!