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 trialelad shor leshem
1,916 PointsCouldn't find `most_courses`
why im getting this error? the code works... tnx
# 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(dic):
return int(len(dic.keys()))
def num_courses(dic):
courses_count = 0
for teacher_course in dic.values():
courses_count += (len(teacher_course))
return (courses_count)
def courses(dic):
all_courses = []
for course in dic.values():
for item in course:
all_courses.append(item)
return (all_courses)
def most_course(dic):
teacher_course_num = {}
for teacher,course in dic.items():
teacher_course_num[teacher]= len(course)
max_vlaue = (max(teacher_course_num.values()))
for teacher,course in teacher_course_num.items():
if course == max_vlaue:
return (teacher)
1 Answer
Kurt Maurer
16,725 PointsHey there,
Your code works, you just need to pluralize most_courses.
Your code:
def most_course(dic):
Replace with:
def most_courses(dic):
Hope this helps!
elad shor leshem
1,916 Pointselad shor leshem
1,916 Pointsooops :)