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 trialTomasz Necek
Courses Plus Student 7,028 PointsNext, create a function named num_teachers that takes the same dictionary of teachers and classes. Return the total numb
I'm lost, can you help me, thank you
def most_classes(dicts):
most_class = ""
max_count = 0
for teacher in dicts:
if len(dicts[teacher]) > max_count:
max_count = len(dicts[teacher])
most_class = teacher
return most_class
def num_teachers(teacher):
print(teacher)
2 Answers
Tomasz Necek
Courses Plus Student 7,028 Pointswhy these tasks cannot JUST check the basic knowledge ? JUST about creating the dictionary etc. Not writing the whole program. It shouldn't be for begginers .
Anyone can help?
Jason Anello
Courses Plus Student 94,610 PointsHi Tomasz,
The num_teachers function can be written in one line and it's going to be a return statement, not a print statement.
As a hint, the length of a dictionary is the number of keys it has.
Jason Anello
Courses Plus Student 94,610 PointsYou only have to use the len() function which you have already used in the previous most_classes function.
A dictionary is going to be passed into your function and each key in that dictionary is a teacher. So getting the number of teachers is the same as getting the number of keys. Getting the length of the dictionary will give you the number of keys it has.
def num_teachers(teacher_dict):
return len(teacher_dict)
Isaac Al-Wahaibi
6,522 PointsIsaac Al-Wahaibi
6,522 Pointsyour dict name is different from Jason
try this one