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 trialEmmanuel Isaac
4,335 PointsI don't quite understand d output you're expecting here. I have "[['Kenneth Love', 2], ['Jason Seifer', 3]]" in terminal
I don't quite understand the expected output. Because, what I have in my terminal is "[['Kenneth Love', 2], ['Jason Seifer', 3]]", and I still cannot progress. Could you shed more light on the expected output pls?
# The dictionary will be something like:
the_dict = {'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(*args, **kwargs):
dicta = the_dict
counter = 0
initial = ""
for key in dicta:
if len(dicta[key]) >= counter:
initial = key
counter = len(dicta[key])
continue
return initial
def num_teachers(*args, **kwargs):
dicta = the_dict
counter = 0
for value in dicta.values():
counter = counter + len(value)
continue
return counter
def stats(*args, **kwargs):
dicta = the_dict
lists = []
for key in dicta:
new_list = []
counter = len(dicta[key])
new_list.append(key)
new_list.append(counter)
lists.append(new_list)
continue
return lists
most_classes(the_dict)
num_teachers(the_dict)
stats(the_dict)
Emmanuel Isaac
4,335 PointsFor num_teachers, I had to do that, cos when I initially tried getting the number of teachers, I was getting an error that goes like this "Expected 5, got 2"... Twas weird, so I figured out that the actual request might be the number of courses, as opposed to finding the number of teachers.
Emmanuel Isaac
4,335 Points@David What do you have to say about the last function? Btw, pls consider the dictionary above
David Bell
16,997 PointsIt looks like the third is falling into the same pitfall with counting character length.
I think Kenneth has the right answer. The challenge isn't necessarily using the same data, but it give an example of the data structure. Trying to get the challenge evaluation to match with the example dict's exact data isn't the goal: its to make a function that can handle any data set the challenge bot will throw into your functions.
1 Answer
Kenneth Love
Treehouse Guest TeacherYou need to actually use the arguments passed to the functions instead of the example dictionary in the comments.
David Bell
16,997 PointsDavid Bell
16,997 PointsHi! I had a moment to take a quick look. Two things I'm seeing: 1) So far as getting the challenge to recognize your functions, I think its looking for a dict value, rather than *args. Again, looking briefly, but I'm wondering if that's helpful... 2) For num_teachers, it looks like you're adding the character length of the value, rather than counting through keys.
Sorry for the brief comment, hope this helps get you on the right track!