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 trialAdam Tyler
14,865 PointsTeachers
For challenge 5 I have been asked to create a function called stats which crates a list of lists each containing the teachers and the number of courses they teach, my function seems to work in workspaces doing exactly as asked but in the challenge I get the message "could not find 'stats'" Have I made a stupid error here? Thank you in advance for any help
# The dictionary will look something like:
# {'Andrew Chalkley': ['jQuery Basics', 'Node.js Basics'],
# 'Kenneth Love': ['Python Basics', 'Python Collections']}
#
# Each key will be a Teacher and the value will be a list of courses.
#
# Your code goes below here.
def num_teachers(arg):
return(len(arg))
def num_courses(arg):
x = 0
for course in arg:
x += len(arg[course])
return(x)
def courses(arg):
list_ = []
for value in arg.values():
list_ += value
return(list_)
def most_courses(arg):
list_nums = []
list_keys = []
for key in arg:
list_nums.append(len(arg[key]))
list_keys.append(key)
return(list_keys[(list_nums.index(max(list_nums)))])
def stats(arg):
stats_list = []
for key in dict_:
stats_list.append([key]+[len(arg[key])])
return(stats_list)
1 Answer
Ari Misha
19,323 PointsHiya Adam! You literally are very very close. Just replace "dict_" with "arg", and you are good to go. (:
Adam Tyler
14,865 PointsAdam Tyler
14,865 PointsArgh obviously, thank you I'm such an idiot!!