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

WILLIAM GILLILAND
WILLIAM GILLILAND
1,393 Points

python dict challenge 1 of 5

im stuck

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({'Andrew Chalkley': ['jQuery Basics', 'Node.js Basics'],
 'Kenneth Love': ['Python Basics', 'Python Collections']}):
    return(

2 Answers

james south
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
james south
Front End Web Development Techdegree Graduate 33,271 Points

the parameter for your function is just an internal variable, not the actual dictionary. so something like dict or my_dict for example. it is the internal representation of the dictionary that will be passed in as the argument when your function is called. in this first task you just need to count and return the number of keys in the dictionary that is passed in.

Steven Parker
Steven Parker
231,248 Points

For starters, you can't define a function using literal parameters.

Also, the challenge said your function "takes a single argument, which will be a dictionary". So you'll need a name for the parameter (just one) that will represent a dictionary when the function is called.

But if you don't know where to go from there, you might want to review the video on Dictionary Iteration which has some examples of things you will want to do in this function.