Python Python Collections Dictionaries Teacher Stats

returning name of the teacher with the most number of courses

am trying task on python collections which need to iterate through the dictionary and return the name of the teacher with the highest number of courses
# 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(tutors):
    count = len(tutors.keys())
    return count

def num_courses(tutors):
    count = 0
    course_list = []
    for name in tutors.keys():
        for course in tutors[name]:
            if course not in course_list:
    return len(course_list)

def courses(tutors):
    avail_courses = []
    for courses in tutors.values():

    return avail_courses

def most_courses(tutors):
    course_count = 0
    teacher_name = ''
    for name, courses in tutors.items():
        lf len(courses) > course_count:
            course_count = len(courses)
            teacher_name = name
    return teacher_name

1 Answer

Alex Koumparos
Alex Koumparos
Python Web Development Treehouse Moderator 30,356 Points

Hi Clainos,

You have a one-character typo in your most_courses function. Where you meant to type if you actually typed lf.