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!
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

Josh Bennett
15,258 PointsWhy is the variable not defined? Looks defined to me.
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):
aList = []
for x in COURSES:
if COURSES[x] & topics:
alist.append(x)
return aList
2 Answers

Andreas cormack
Python Web Development Techdegree Graduate 33,011 PointsHi Josh
Your list is called aList, but your appending to a list called alist ? alist is obviously not defined. Also not sure whats
if COURSES[x] & topics:
is doing.
I did the same thing in a slightly different way.
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):
aList = []
for key,val in COURSES.items():
if key == topics:
aList.append(val)
return aList

Josh Bennett
15,258 PointsSon of a.... Well thats what I get for coding before 5 am. Lesson learned. :-)

Andreas cormack
Python Web Development Techdegree Graduate 33,011 Pointsson of a, I do that all the time haha