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![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![charlesmonaghan](https://uploads.teamtreehouse.com/production/profile-photos/7819552/micro_12801518_1128022470564562_190720762099795161_n.jpg)
charlesmonaghan
742 PointsI believe I did this right, but I'm not sure why it's not working?
I'm pretty sure I got everything right. But it just returns the error "Bummer! Try again!".
# E.g. word_count("I do not like it Sam I Am") gets back a dictionary like:
# {'i': 2, 'do': 1, 'it': 1, 'sam': 1, 'like': 1, 'not': 1, 'am': 1}
# Lowercase the string to make it easier.
def word_count("this is a string"):
return {'this': 1, 'is': 1, 'a': 1, 'string': 1}
2 Answers
![Logan R](https://uploads.teamtreehouse.com/production/profile-photos/483382/micro_profilepicture.jpg)
Logan R
22,989 PointsI think you're reading the comments wrong. It's saying it will run your code with those parameters.
# The function you write
def word_count(words_as_string):
# Make a new dictionary for words and their count.
word_dict = {}
# Sum words
# ...
return word_dict
# --------------------------
# You "can't see" this code, but this is how they will call your function
word_counts = word_count("I do not like it Sam I Am")
# Expected dictionary back:
# >>> print (word_counts)
# {'i': 2, 'do': 1, 'it': 1, 'sam': 1, 'like': 1, 'not': 1, 'am': 1}
Hopefully, this helps clear up question!
![Christian Lamoureux](https://secure.gravatar.com/avatar/9d9f49f92742bc3d5d158f178dffa453?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Christian Lamoureux
Full Stack JavaScript Techdegree Student 22,669 PointsI also am struggling with this one here's what I have so far def word_count(value): the_dictionary = {} value = value.lower() my_list = [''.split(value)] word_list = [] for word in my_list: word_list.append(word) if word == word in word_list: word = str(word) number = [] number.append(word) length = len(number) the_dictionary.update({word: length})
else:
the_dictionary.update({word: 1})
continue
return the_dictionary