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 trialAlexander Löwenmark
1,664 Points*[SOLVED]* Bummer! Even though my function works as intended.
Am I missing something here?
It works when I run it locally on my computer but the test says "Bummer! Didnt get the expected results...."
# 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(indata):
custom_dic = {}
word_feeded = indata.lower().split(" ")
for word in word_feeded:
if word in custom_dic.keys():
count = custom_dic[word] + 1
custom_dic[word] = count
else:
custom_dic[word] = 1
return custom_dic
Moderator edit: Marked as solved, as per comment by Poster
Steven Parker
231,060 PointsCongratulations on resolving your issue!
And many folks encounter the same issue, evidenced by the othe questions in the forum archives.
Alexander Löwenmark
1,664 PointsAlexander Löwenmark
1,664 PointsOk, I figured it out myself.
I used split on spaces split(" ") when instead you should not pass any arguments to the split method so that it splits on all white space like so: split().