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 trialvictor E
19,146 Pointsneed help on this one too :(
whats wrong with my code!?
# 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):
counter = 0
for value in dictionary.values():
counter += len(value)
return counter
def courses(dictionary):
library = []
for items in dictionary.values():
library.extend(items)
return library
def most_courses(teachers):
max = 0
teacher = ""
for key, value in teachers.items():
if len(value) > max:
max = len(value)
teacher = key
return teacher
def stats(dictionary):
for key, in dictionary:
new = key, len(value)
return list(new)
1 Answer
Joseph Yhu
PHP Development Techdegree Graduate 48,638 PointsHere's what I did.
def stats(dictionary):
new = []
for key, value in dictionary.items():
new.append([key, len(value)])
return new
victor E
19,146 Pointsvictor E
19,146 Pointsbeautiful!! thanks!!