dictionary = {'Jason Seifer': ['Ruby Foundations', 'Ruby on Rails Forms', 'Technology Foundations'], 'Kenneth Love': ['Python Basics', 'Python Collections'], 'Daniel': ['Python Basics', 'Python Collections', 'test', 'test']}
def most_class(dictionary):
current_count = 0
max_count = 0
best_teacher = "none"
for key in dictionary:
for values in dictionary.values():
current_count += 1
if current_count > max_count:
max_count = current_count
best_teacher = key
return best_teacher
The goal is to determine which key in the dictionary has the most values. The answer should be Daniel, but I am getting a different answer each time I run the code (presumably due to pythons hashing of the dictionary.
Can anyone explain why I am getting this result, and how it can be fixed?