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 trialNicolae Laurentiu
1,538 PointsHello, I don't understand why I get this problem. Could you please help me with an explanation? Thank you
I run the code in the workspace and it worked.
# 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(dictT):
listOfT = []
for item in dictT:
listOfT.append(item)
return len(listOfT)
def num_courses(dicT):
listOfC = []
for item in dicT.values():
listOfC += item
print(len(listOfC))
1 Answer
Anthony Crespo
Python Web Development Techdegree Student 12,973 PointsYour num_courses function actually don't return anything. In the last line you print the result instead of returning it. You did good in everything else, I just tested the code in the challenge.
def num_courses(dicT):
listOfC = []
for item in dicT.values():
listOfC += item
return(len(listOfC))