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 trial

Python Python Collections (Retired) Dictionaries Teacher Stats

most_classes() takes 0 positional arguments but 1 was given.

Here, I'm attempting to return the teacher (Friend) from teacher_dict with the most classes (Languages). However, it says I have a positional argument, and I'm not quite sure what it means by that. I wasn't quite sure either how the **dict_name method worked, so if you could explain that a bit to me, It'd be appreciated. Thanks.

teachers.py
# 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
teacher_dict = {'Yuki': ['Japanese', 'German', 'English'], 'Avi': ['English'], 'Jean': ['Philipino', 'English']}
def most_classes():
  max_count = 0
  best_teach = []
  for person in teacher_dict:
    subjects = len(person[key])
    if subjects > max_count:
      best_teach = person
      max_count = subjects
      the_teacher = {'classes': max_count, 'name': best_teach}
  return ("Mr. {} has the most classes. ({})").format(**the_teacher)

2 Answers

Kenneth Love
STAFF
Kenneth Love
Treehouse Guest Teacher

Your function doesn't accept any arguments but it should. You need to do the work (figuring out the teacher with the most classes) on the dictionary that comes in, not on one you've defined in the file.

Thanks, I can never figure out whether I need to do one on my own or let one come in.

Kenneth Love
Kenneth Love
Treehouse Guest Teacher

You'll pretty much always let one come in.