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

Josh Keenan
Josh Keenan
20,315 Points

most_classes() funciton: Dictionaries

Tried using it as an argument input but get told that most_classes doesn't exist, or with this style I get told that a 'postitional argument was given but got none'

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.
def most_classes():
  dictionary = input('dict plz')
  list1 = []
  list2 = []
  high = 0
  pos = 90

  for key in dictionary:
    list1.append(key)

  for item in dictionary:
    length = len(item)
    list2.append(length)

  for index in list2:
    if index > high:
      high = thing
      pos = index

  return list1[pos]

2 Answers

Chi-Shiang Wang
Chi-Shiang Wang
3,471 Points

I think you lost the argument(s) in your most_classes function

change it to "def most_classes(dicts):"

And you need to notice that the input dictionary will be something like :

{'Jason Seifer': ['Ruby Foundations', 'Ruby on Rails Forms', 'Technology Foundations'],

'Kenneth Love': ['Python Basics', 'Python Collections']}

so, your function should to handle this data format in this challenge.

hope it can help you to solve your problem :-)

Josh Keenan
Josh Keenan
20,315 Points

still getting the same problem, i think it may be something client side perhaps as i tried some code on my own python and it ran so i'm confused.

added

Found solution to the problem, signed in and out again and my code works, thank you very much though :) high five

Josh Keenan
Josh Keenan
20,315 Points

Thanks but that's what I did originally and that wouldn't run, and tested that the code there can handle and instance like that..

Josh Keenan
Josh Keenan
20,315 Points

I get "Bummer Where's 'most_classes()'?"

Chi-Shiang Wang
Chi-Shiang Wang
3,471 Points

Your code it seem like to make new function, allow user to input new dicts and find the most classes. >_<

In my opinion, I think the purpose of this challenge, which is want you to find which one have the most classes in below dicts.

{ 'Jason Seifer': ['Ruby Foundations', 'Ruby on Rails Forms', 'Technology Foundations'], 'Kenneth Love': ['Python Basics', 'Python Collections'] }

Therefor, your code will be something like:

def most_classes(teachers):
    max_count = 0
    for teacher in teachers:
    print (len(teacher))
    if len(teacher)>max_count:
        max_count = len(teachers[teacher])
        print("{} {}".format(teacher, max_count))
        new_winner = teacher
    return new_winner

hope it can help you to finish it :-)