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 trialMarc Differding
3,252 PointsI don't understand why my codes isn't accepted in teachers.py 3/3. It outputs the exact required values in a list.
def stats(teachersDictionary):
teachersLt = []
classesLt = []
numberOfClassesLt = []
statsLt = []
for teacher in teachersDictionary.keys():
teachersLt.append(teacher)
if teacher in teachersDictionary:
numClasses = len(teachersDictionary.get(teacher))
classes = teachersDictionary.get(teacher)
numberOfClassesLt.append(numClasses)
classesLt.append(classes)
for i in range(len(teachersLt)):
statsLt.append(teachersLt[i])
statsLt.append(numberOfClassesLt[i])
return statsLt
1 Answer
Kenneth Love
Treehouse Guest TeacherI updated the code challenge to better show you the output that stats()
gives. Your code is good except you're not returning a list of lists (one inside list per teacher), you're only returning one list.
Marc Differding
3,252 PointsMarc Differding
3,252 PointsHehe, thank you. I guess I hadn't read the task correctly. I figured it out now. I now use a temporary list for the individual teacher stats and another list for the stats: