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 trialJeremy Nootenboom
Python Web Development Techdegree Student 6,876 PointsCode returns the desired output in Workspaces. Why won't the challenge (#5, stats) accept it?
Using the example dictionary provided:
teacher_dict = {'Andrew Chalkley': ['jQuery Basics', 'Node.js Basics'],
'Kenneth Love': ['Python Basics', 'Python Collections']}
And the following function:
def stats(teacher_dict):
lists = []
for teacher in teacher_dict:
teacher_dict[teacher] = len(teacher_dict.get(teacher))
for teacher, courses in teacher_dict.items():
lists.append([teacher, courses])
return(lists)
Output is as follows:
[['Andrew Chalkley', 2], ['Kenneth Love', 2]]
Is this not precisely what the question asked for? Not sure why my original code was not accepted?
Thanks in advance for taking a look!
-Jeremy
1 Answer
Steven Parker
231,269 PointsI suspect the issue is that the challenge does not want you to modify the original data while preparing the stats list.
I would have confirmed this in the challenge, but you forgot to provide a link to the challenge page.