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 trialKade Carlson
5,928 PointsNot sure what to do for the task
I've been trying this for a couple days and I still can't get it
# 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(val):
for prop in val:
return len(val)
def num_courses(val):
course = 0
for item in val.values():
course += len(item)
return course
def courses(val):
all_courses = []
for prop in val:
all_courses.extend(val[prop])
return all_courses
def most_courses(val):
for prop in val:
v = max(len(val.values()))
return prop[v]
1 Answer
Tonye Jack
Full Stack JavaScript Techdegree Student 12,469 PointsThese are one liners to solve all of it reply if you need more help
num_teachers = lambda arg: len(arg.keys())
num_courses = lambda arg: sum([len(c) for c in arg.values()])
courses = lambda arg: [c for s in arg.values() for c in s]
most_courses = lambda arg: [t for t, c in sorted(arg.items(), key=lambda a: len(a[1]), reverse=True)][0]
stats = lambda arg: [[t, len(c)] for t, c in arg.items()]