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 trialNathan English
Front End Web Development Techdegree Student 10,817 PointsNeed help! I'm having trouble understanding.. What am I missing??
It's official: you're awesome at Python dictionaries! One last task and then you can take a well-deserved break!
In this last challenge, I want you to create a function named stats and it'll take our teacher dictionary as its only argument.
stats should return a list of lists where the first item in each inner list is the teacher's name and the second item is the number of courses that teacher has. For example, it might return: [["Kenneth Love", 5], ["Craig Dennis", 10]]
# The dictionary will look something like:
# {'Andrew Chalkley': ['jQuery Basics', 'Node.js Basics'],
# 'Kenneth Love': ['Python Basics', 'Python Collections']}
#
# Each key will be a Teacher and the value will be a list of courses.
#
# Your code goes below here.
def stats(my_dict):
showcase = []
for teacher,num_of_courses in my_dict.item():
showcase.append = ([teacher,len(num_of_courses)])
return showcase
1 Answer
Dave StSomeWhere
19,870 PointsYou're very close...
2 errors found - does that point you in the right direction?
for teacher,num_of_courses in my_dict.item(): # just a missing letter on this line
showcase.append = ([teacher,len(num_of_courses)]) # why are you using assignment - should be function call