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

Have been coding Python full-on for x3 weeks and my code is still seriously ugly. Any ideas/help appreciated!

Please see code attached. Have been coding Python for x3 weeks now and have more and more been relying on the steps written /other people's community input to make it through the Python Collections course. Also it is taking ages to get the right answers and code that I write still looks way ugly and is the long way round problems. Any ideas, thought, help if possible? Thinking of exit() \n clear from Python for good after this course. Is this progress standard? Kenneth Love

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.
dict = {'Jason Seifer': ['Ruby Foundations', 'Ruby on Rails Forms', 'Technology Foundations'], 'Kenneth Love': ['Python Basics', 'Python Collections']}

def most_classes(dict):
    max_count = 0
    for key in dict:
        if len(dict[key]) > max_count:
            max_count = len(dict[key])
            top_teach = key
    print(top_teach)

most_classes(dict)

2 Answers

Kenneth Love
STAFF
Kenneth Love
Treehouse Guest Teacher

Your code isn't ugly at all!

And, yeah, programming is hard. Sometimes it takes awhile to catch on. Sometimes you have to rely on the community and other people for examples and answers. I do it all the time.

Jeff Hartl
seal-mask
.a{fill-rule:evenodd;}techdegree
Jeff Hartl
Python Web Development Techdegree Student 8,420 Points

Alex, If you just started learning to code in Python 3 weeks ago, I'd say your progress is pretty good -- at least based on the code you posted as an example. It looks pretty similar to what I wrote for that same exercise. I've been trying to learn Python for many months and I still write "ugly" code. Don't bail out yet!

Is it Python in particular that's got you ready to exit?