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

Aishwarya Manicka Ravichandran
seal-mask
.a{fill-rule:evenodd;}techdegree
Aishwarya Manicka Ravichandran
Python Web Development Techdegree Student 3,679 Points

Challenge task 3 of 5 : wrong in my program

I keep getting this error "Could'nt find num_teachers" Dont know whats wrong in my program

teachers.py
def num_teachers(dictionary):
    key_count = 0
    for keys in dictionary.keys():
        key_count +=1
    return key_count
def num_courses(dictionary):
    value_count = 0
    for values in dictionary.values():
        for item in values:
            value_count+=1
    return value_count
def courses(dictionary):
    list_of_courses = []
    for value in dictionary.values():
        list_of_courses.extend(values)
    return list_of_courses

dictionary = {'Andrew Chalkley': ['jQuery Basics', 'Node.js Basics'],
                     'Kenneth Love': ['Python Basics', 'Python Collections']}
num_teachers(dictionary)
num_courses(dictionary)
courses(dictionary)

1 Answer

Karanveer Singh
PLUS
Karanveer Singh
Courses Plus Student 7,472 Points

The only thing wrong in your program is on line 15. Correct the spelling mistake:

list_of_courses.extend(values)

to

list_of_courses.extend(value)

and also you have not defined any variables to which your functions will return values to.