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
mijurg
16,044 PointsIt works on PyCharm , but workspaces doesnt accept it. Why??
This is the challenge on "word_count"
This code works fine using IDE pycharm. i can't understand why workspaces giving me an error "Hmm, didn't get the expected output. Be sure you're lowercasing the string and splitting on all whitespace!"
What is wrong here???
my code and what i am missing is here:
def word_count(string):
lower_cased_string = string.lower()
list_from_string = lower_cased_string.split(" ")
new_dict = {}
for item in list_from_string:
new_dict[item] = list_from_string.count(item)
return new_dict
1 Answer
Kenneth Love
Treehouse Guest TeacherYour code is fine minus one bad assumption. You're splitting on explicit spaces. What is the string has tabs or newlines in it? Just use .split().
mijurg
16,044 Pointsmijurg
16,044 PointsThanks, i already found that mistake.