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 trialArkadiusz Podg贸rski
2,588 PointsTeacher Stats Task 3/4; Task 1 no longer passing
The problem here lies, I suppose, in the first function, most_classes. BUT it passed reliably in both previous Tasks. I'm a bit confused, as the code of this first function was not altered in any way.
# The dictionary will be something like:
# {'Jason Seifer': ['Ruby Foundations', 'Ruby on Rails Forms', 'Technology Foundations'],
# 'Kenneth Love': ['Python Basics', 'Python Collections']}
#
# Often, it's a good idea to hold onto a max_count variable.
# Update it when you find a teacher with more classes than
# the current count. Better hold onto the teacher name somewhere
# too!
#
# Your code goes below here.
def most_classes(teach_dict):
max_count = 0
max_classes = ''
for teacher, classes in teach_dict.items():
if len(classes) > max_count:
max_count = len(classes)
max_classes = teacher
return max_classes
def num_teachers(teach_dict):
count = 0
for teacher in teach_dict:
count += 1
return count
def stats(teach_dict):
stat_list = [,]
for teacher in teach_dict:
stat_list.append([teacher, len(teach_dict[teacher])])
return stat_list
Arkadiusz Podg贸rski
2,588 PointsArkadiusz Podg贸rski
2,588 PointsOkay, nevermind. Apparently the issue was with incorrectly defined empty stat_list. The comma is required only when creating tuples... Still have no idea why it stopped Task 1 from completion.