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 trialSergei Miroshnikov
3,313 PointsVague error message with correct output .
I am getting error message with exactly same output as requested :( . I would love to solve this but I do not understand what is wrong .
def most_classes(teachers_dict):
result_disct = {}
maxValue = 0
for key in teachers_dict:
if len(teachers_dict[key]) > maxValue:
maxValue = len(teachers_dict[key])
result_disct = {key: len(teachers_dict[key])}
return list(result_disct.keys())[0]
def num_teachers(teachers_dict):
teachercounter = 0
for key in teachers_dict:
teachercounter += 1
return teachercounter
def stats (teachers_dictionary):
return list (result)
def stats(x):
teacher_list =[]
for key in x:
teacher_list.append(key)
teacher_list.append(len(x[key]))
return teacher_list
1 Answer
Chris Freeman
Treehouse Moderator 68,441 PointsYour code isn't returning exactly what is expected. The challenge is asking for a list of lists, where each contained list has the teacher name and the course count: [['teacher1', 3], ['teacher2', 7], ...]
You can achieve this by combining your two append statements:
## Change ##
teacher_list.append(key)
teacher_list.append(len(x[key]))
## to ##
teacher_list.append([key, len(x[key])])