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 trial
yenny panceta
130 PointsWhat i am doing wrong with this function? on teacher stats
Now, create a function named stats that takes the teacher dictionary. Return a list of lists in the format [<teacher name>, <number of classes>]. For example, one item in the list would be ['Dave McFarland', 1].
i am using this function:
def stats(teachers): my_list = [] full_list = [] for key in teachers: my_list.append(key) my_list.append(len(teachers[key])) full_list.append(my_list) my_list = [] return full_list
i tested and do the job, but not sure why is not passing . Thanks
2 Answers
Vidhya Sagar
1,568 PointsYou're code is fine,maybe somewhere you missed the indendation. Try this
def stats(teachers):
my_list = []
full_list = []
for key in teachers:
my_list.append(key)
my_list.append(len(teachers[key]))
full_list.append(my_list)
my_list = []
return full_list
yenny panceta
130 Pointsits indented and working fine outside of treehouse, thanks anyway for you answer.