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 trial

Python Python Collections (2016, retired 2019) Dictionaries Teacher Stats

Wow, I just can't stump you! OK, two more to go. I think this one's my favorite, though. Create a function named most_c

i am getting the Error that says: "It looks like Task 3 is not passing anymore." And when i go back to task 3 it still passes. HELP

teachers.py
# 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):
    teacher_count = 0
    for teacher in teachers:
        teacher_count +=1    
    return teacher_count

def num_courses(teachers):
    total_courses = 0
    for value in teachers.values():
        for course in value:
            total_courses +=1    
    return total_courses


def most_courses(teachers):
    max_courses = 0
    bestteacher = ""
    for key,value in teachers.item():
        if len(values)> max_courses:
            max_course = len(value)
            bestteacher = teacher
    return bestteacher
nakalkucing
nakalkucing
12,964 Points

Hi! Could you post your just plain "courses" function? I'd love to help but I really can't with only part of your code. : ) Thanks, Nakal

for some reason this i s omitting my courses function. S o it doesn't show up on the board when i get to step4

Here is all the steps, but i had to copy step 3 then paste it into step 4 stage. I don't know why when i get to step 4 it automatically omit the step 3 function which is the courses function

nakalkucing
nakalkucing
12,964 Points

In "most_courses" why do you have

bestteacher = ""

? It might work fine. But I didn't use an empty string in my code, and I just wondered if you could tell me. Thanks.

nakalkucing
nakalkucing
12,964 Points

Do you mean that the challenge itself omits task 3 every time you come to task 4?

yes i does

nakalkucing
nakalkucing
12,964 Points

Ok. Have you tried leaving the challenge, doing something else, and then retrying the challenge?

1 Answer

i have restarted the challenge, here it is now. I am stil stuck def num_teachers(teachers): teacher_count = 0 for teacher in teachers: teacher_count +=1
return teacher_count

def num_courses(teachers): total_courses = 0 for value in teachers.values(): for course in value: total_courses +=1
return total_courses

def courses(teachers): total_courses = [] for value in teachers.values(): total_courses += value
return total_courses

def most_courses(teachers): max_courses = 0 bestteacher = "" for key,value in teachers.item(): if len(values)> max_courses: max_course = len(value) bestteacher = teacher return bestteacher

nakalkucing
nakalkucing
12,964 Points

Ok. I don't see the purpose of

besteacher = ""

in the fourth function of your code. You might try completely removing that line. : ) Hope that fixes it, Nakal