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

Dennis Stephens
Dennis Stephens
2,864 Points

Code works on personal terminal but challenge not passing

Please see attached code. I run this at home and get an output of 4 which is correct. Not sure why the code challenge is not being accepted. Thank you

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.

arg = {'Andrew Chalkley': ['jQuery Basics', 'Node.js Basics'],
  'Kenneth Love': ['Python Basics', 'Python Collections']}

def num_teachers(arg):
     return len(arg)

def num_courses(arg):
    new_list = []
    for value in arg:
        new_list.append(len(arg[value]))
    total = sum(new_list)
    return total
Rich Zimmerman
Rich Zimmerman
24,063 Points

which step are you on? I just copied your code and it passed up to step 3 where you create a new function that you do not have in your code block here.

1 Answer

Dennis Stephens
Dennis Stephens
2,864 Points

Thank you for your response. I just figured it out. I need to just add # to arg input. I needed that part for my own terminal but Treehouse passes its own argument.