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!

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 (2016, retired 2019) Dictionaries Word Count

Not sure what to do next plz help

plz send the image of the code which plays the solution to this question

# 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(string):
Jennifer Nordell
Jennifer Nordell
Treehouse Teacher

Posting of explicit answers which can be copy/pasted into the challenge to pass with no explanation is frowned upon by Treehouse. People are more likely to help you with this if you at least post a "good faith" attempt. So far, all I see is the definition of the word_count function. I would prefer to see more of an effort on your part. This is ultimately for your own benefit.

:bulb: Hint: try doing the code in a workspace first and see if your code can produce the output required.

1 Answer

So, since you need to count words, you need to split the string up into words first.

Since you need to return a dictionary, you'll need to create one, and then the values in the dictionary will be each of the unique words, so you need to determine if the word you're adding already exists (since they won't automatically have a count of zero by default).

Hope that helps!