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

My solution produces the right results, but the challenge doesn't accept it.

I've found another, shorter solution, but I'm wondering why my solution below hasn't been accepted by the challenge?

def word_count(astring):
    dict1 = {}
    a = astring.lower()
    string_list = list(set(a.split()))
    for i in string_list:
        dict1.update({i:a.count(i)})
    return dict1

1 Answer

it doesn't produce the right results for me. try it on this 'i am sam said sam i am I AM i am sam'. it is counting the am in sam as am and also the i in said as an i.