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 trialMichael Aronian
Python Web Development Techdegree Student 5,453 PointsI am having trouble list a single list of all the classes in a dictionary.
I am really stuck on this question.
dictionary = {'Andrew Chalkley': ['jQuery Basics', 'Node.js Basics'], 'Kenneth Love': ['Python Basics', 'Python Collections']}
def num_teachers(dictionary):
number = len(dictionary)
return(number)
num_teachers(dictionary)
def num_courses(dictionary):
ctr = sum(map(len, dictionary.values()))
return(ctr)
num_courses(dictionary)
def courses(dictionary):
school= list(dictionary.values())
for course in school:
for classes in course:
print(classes)
courses(dictionary)
1 Answer
Pete P
7,613 PointsI think you mostly have it. Where you have print(classes), you could, instead, append the classes to some classes_list and then return the classes_list.
Hope that helps!