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 trialOtis Riege
2,260 PointsThis answer works perfectly on pycharm... what gives?
What gives? this code words perfectly on pycharm.
def word_count(x):
dic = {}
words = x.lower().split()
for word in words:
dic.update({word: words.count(word)})
return dic
3 Answers
Chris Freeman
Treehouse Moderator 68,441 PointsYou have a mix of spaces and tabs in your code indentation. The code challenges flag that as an error. I suggest only using spaces.
Otis Riege
2,260 PointsThanks Chris, but how did you know that just by looking at the code?
Chris Freeman
Treehouse Moderator 68,441 PointsI canβt necessarily βsee itβ. If i run your code as posted and it passes then it must be a hidden syntax issue. I then grab your code and run it in my local REPL. The inconsistent use error then pops up.
Some editors automatically correct indentation errors on a cut and paste.
Otis Riege
2,260 PointsOh ok that makes more sense. Just to reiterate, instead of using tab, I should use 4 spaces every time I want to indent a line of code?
Chris Freeman
Treehouse Moderator 68,441 PointsCorrect. 4 spaces over using Tabs