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 trialJoseph Raker
Courses Plus Student 3,354 PointsReceiving error "Bummer! Couldn't find 'most_courses'". Can't figure out why!
I know others are having this problem, but I have not found a solution. Thank you and your help is appreciated.
# 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(teachers):
return len(list(teachers.keys()))
def num_courses(teachers):
return sum(len(v) for v in teachers.values())
def courses(teachers):
output = []
for courses in teachers.values():
output +=courses
return output
def most_courses(teachers):
leader = 0
teachermost = ""
for key, value in teacher.items():
if len(value) > leader:
leader = len(value)
teachermost = key
return teachermost
1 Answer
Ryan S
27,276 PointsHi Joseph,
The error message is not very informative, but a lot of the time when you get the "Couldn't find..." error and you clearly have the function defined, you can usually trace it back to something related to the function definition itself.
In this case, you passed in a "teachers" argument (plural), but you are trying to iterate through "teacher" (singular). This mismatch of the function argument is causing the error.
Hope this helps.
Joseph Raker
Courses Plus Student 3,354 PointsJoseph Raker
Courses Plus Student 3,354 PointsThank you!!