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 trialDavid Chacón
1,086 PointsUnsure of where I'm going wrong, teachers.py step 5/5
I can feel I'm close. I'm just not sure what I'm missing.
No answers please, just a hint in the right direction would be great!
# 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(teachers):
count = 0
for teacher in teachers:
count += 1
return count
def num_courses(courses):
count = 0
for i in courses:
count += len(courses[i])
return count
def courses(courses):
count = []
for i in courses:
count += courses[i]
return count
def most_courses(teacher):
leader = 0
teacherMost = ""
for i in teacher:
if len(teacher[i]) > leader:
leader = len(teacher[i])
teacherMost = i
return teacherMost
def stats(teacher):
stats = []
for i in teacher:
stats += [i, len(teacher[i])]
return stats
1 Answer
David Chacón
1,086 PointsOMG James thank you! That hint was perfect! So close.... so close.
Jamie Marsay
8,320 PointsJamie Marsay
8,320 PointsHi there, David!
You're very close to the solution, but if you'd like a clue, it has to do with this line:
+= is used for adding integers to integers, not appending items to a list.
Hope this makes it slightly clearer for you!
Let me know if you need further help!
James.