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

I don't know what is wrong with my code. I keep getting the message that it's incorrect.

I've solved this in a few of different ways and it worked in workspaces each time but it doesn't work when I submit it.

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(dict):
    teachers = len(dict)
    return teachers

def num_courses(dict):
    courses = []
    for value in dict.values():
        courses += value
    return len(courses)

1 Answer

Alex Koumparos
seal-mask
.a{fill-rule:evenodd;}techdegree
Alex Koumparos
Python Development Techdegree Student 36,887 Points

Hi Asia,

Which task are stuck on? I see that you've provided your code for tasks 1 and 2. When I copy-pasted your code into the challenge I was able to pass the first two tasks.

If you are having issues with task 2, I suggest you close and reopen your browser and then try copy-pasting your code above back into to the challenge.

If you are having issues with a later task, please update your question with your code that is failing the task.

Cheers,

Alex