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

Python

word_count passing on my local computer, not in the challenge environment

The test I am running on my computer with the following code returns the expected output - still I am failing to pass the challenge. I have looked at other questions on the site but the suggestions have not brought me further. Any pointers? :-) Thanks everyone!

def word_count(string):
    lst = string.split(" ")
    dct = {}
    for i in lst:
        dct.update({i.lower(): string.count(i)})
    return dct

1 Answer

Jason Anders
MOD
Jason Anders
Treehouse Moderator 145,863 Points

Hi Nathan,

You did not link to the challenge, so I can only guess based on what I possible remember about this challenge. It is always a best practice to click the "Get Help" button from within the challenges (or quizzes or videos) as this will link the code challenge in question and you code, so we can verify the instructions and help you debug.

Fortunately, there were a couple questions posted about this challenge recently. If I remember correctly, the instructions ask you to split on **all** whitespace, but you are splitting only on spaces. If you just correct that, it should pass.

Another good note to remember: Just because it passes in Workspaces or on your local machine, does not mean it will pass the challenge. The instructions for challenges are very specific and the code checker is extremely picky. If you do not have exactly what the instructions ask for, the challenge will fail. Even something as simple as a missing period or a minor typo in a string will usually break the challenge and give you the Bummer.

If it still isn't solved, would you post again from the challenge, it'll help greatly to assist.

Keep Coding! :) :dizzy: