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 trialjahabeebs
3,804 PointsHelp creating a function most_courses that takes teachers and their courses, then returns name of teacher w/most courses
So, a dictionary of teachers and their varying courses is passed through a method I need to make called most_courses that should return the name of the teacher with the most courses. I am not sure why my code isn't working correctly. Any advice?
def most_courses(teachers_and_courses):
max_count = max(teachers_and_courses.values())
for teacher in teachers_and_courses:
if teacher_and_courses.values() == max_count:
return teacher