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 trialWILLIAM GILLILAND
1,393 Pointspython dict challenge 1 of 5
im stuck
# 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
Front End Web Development Techdegree Graduate 33,271 Pointsthe 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
231,271 PointsFor 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.