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 trialAndreas cormack
Python Web Development Techdegree Graduate 33,011 PointsPython collection
struggling to get the stats function to return the right output?? can anyone help
# The dictionary will be something like:
# {'Jason Seifer': ['Ruby Foundations', 'Ruby on Rails Forms', 'Technology Foundations'],
# 'Kenneth Love': ['Python Basics', 'Python Collections']}
#
# Often, it's a good idea to hold onto a max_count variable.
# Update it when you find a teacher with more classes than
# the current count. Better hold onto the teacher name somewher
# too!
#
# Your code goes below here.
def most_classes(my_dict):
my_new_list=[]
max_value=""
for key,value in my_dict.items():
my_new_list.append(value)
max_value=max(my_new_list)
if my_dict[key]==max_value:
return key
def num_teachers(my_dict_one):
return len(my_dict_one)
def stats(my_dict_two):
my_new_list=[]
for key,value in my_dict_two.items():
my_new_list.append("{},{}".format(key,','.join(value)))
return my_new_list
1 Answer
Chris Freeman
Treehouse Moderator 68,441 PointsYou appear to be returning a list of stings instead of a list of lists as mentioned in the challenge. Instead of appending a formated string, append a list consisting of the teacher name and the course count, such as:
[ "Kenneth Love", 5]