Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Python Python Collections (Retired) Dictionaries Teacher Stats

How do I get rid of the single quotes inside each list?

Also, do I need to put <> back around the teacher names and number of classes?

teachers.py
# The dictionary will be something like:
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(teacher_dict):
    teacher_list = []
    class_list = []
    for teacher in teacher_dict:

        class_count = len(teacher_dict[teacher])
        teacher_list.append(teacher)
        class_list.append(class_count)
    location = class_list.index(max(class_list))
    print(location)
    return(teacher_list[location])

most_classes(dict)


def num_teachers(teacher_dict):
    print(len(teacher_dict))
    return len(teacher_dict)

num_teachers(dict)

def stats(teacher_dict):
    stringList = []
    for teacher in teacher_dict:
        num= len(teacher_dict[teacher])
        dict_temp= {'name':teacher, 'number of classes':num}
        temp =['']
        temp[0] = "{name}, {number of classes}".format(**dict_temp)
        stringList.append(temp)
    print(stringList)
    return(stringList)

stats(dict)

2 Answers

Ryan Ruscett
Ryan Ruscett
23,307 Points

Not sure what you are suggestion? Your code works fine, well all except for the dict that you uncommented. You can comment that back out since the dict is being passed in and the one at the top of the project is just for reference. So you can try it out in an interpreter or whatever.

If you can be more specific or give an example of an output where you want to remove .

Thanks!

It runs fine but I am not sure why I get "Bummer! Didn't get the expected output." What is the excepted output?