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 trialTrevor McGill
1,409 PointsHelp with counting courses
I'm trying to differentiate between the keys/values when doing the num_courses function, but I can't get it to count the courses alone. I know that my return statement is off...just trying to figure out a way to count the courses...
# 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(dictionary):
return len(dictionary)
def num_courses(dictionary):
return {num_teachers(dictionary.keys()): len(course) for course in dictionary.values()}
1 Answer
Antonio De Rose
20,885 Pointsdef num_courses(dictionary):
return {num_teachers(dictionary.keys()): len(course) for course in dictionary.values()}
# few mistakes
# return why is it followed by a curly
# can you try break your code line after line
# does not matter if it wrong, post it back, and I can help you.