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 trialFaisal Rana
Python Web Development Techdegree Student 2,008 PointsHelp me with this ! Can anybody tell me what is wrong with my code?
For this first task, create a function named num_teachers that takes a single argument, which will be a dictionary of Treehouse teachers and their courses.
The num_teachers function should return an integer for how many teachers are in the dict.
# 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(treehouse_teachers):
treehouse_teachers = {'Andrew Chalkley': ['jQuery Basics', 'Node.js Basics'],'Kenneth Love': ['Python Basics', 'Python Collections']}
for key in treehouse_teachers:
key = [int(key)]
return num_teachers
1 Answer
Jennifer Nordell
Treehouse TeacherHi there, Faisal Rana ! I feel like you have fallen victim to the "over thinking things" monster that also sometimes pops up and gets me, too. So I'm going to leave a couple of hints here and see if we can get you there.
- You do not need a loop
- This step can be solved in one line of code
- Did you know that you can get the
len
of a dictionary?
I think you can get it with these hints, but let me know if you're still stuck!
Faisal Rana
Python Web Development Techdegree Student 2,008 PointsFaisal Rana
Python Web Development Techdegree Student 2,008 PointsThanks Jennifer, Now I get it.