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 trialBrent Liang
Courses Plus Student 2,944 PointsTask 1 no longer passing
The three previous paragraphs are all correct.
The objective for task 4, which I attempted in the last block of code, is to extract all classes taught by teachers into a single list.
With this code below it keeps saying that task 1 is no longer passing, what's the problem?
# 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 (dicts):
max_count = 0
for dicta in dicts:
count = len(dicts[dicta])
if count > max_count:
max_count = count
name = dicta
return name
def num_teachers (dicts):
num = 0
for dicta in dicts:
num += 1
return num
def stats (dicts):
result_list = []
for dicta in dicts:
teacher_name = dicta
teacher_class = len(dicts[dicta])
result_list.append([teacher_name,teacher_class])
return result_list
def courses (dicts):
hey_list = []
for dicta in dicts:
for item in dicts[dicta]:
hey_list.append(item)
return hey_list
1 Answer
Name:GoogleSearch orJonathan Sum
5,039 PointsYou need a indented block at the last two lines. Do u see the for statment? At the next line of for statment, u need a indented block.
Brent Liang
Courses Plus Student 2,944 PointsThanks Jonathan!
Steven Parker
231,275 PointsSteven Parker
231,275 PointsGot your message, looks like "GoogleSearch" beat me here.