Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Python Python Collections (2016, retired 2019) Dictionaries Teacher Stats

Need 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
Dave StSomeWhere
19,822 Points

You'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