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 Python Collections (Retired) Dictionaries Word Count

Bummer! Where's 'word_count()"?

Code challenge keeps asking where 'word_count()' is. Not sure what to do here.

    def word_count(rand_str):
      rand_lst = rand_str.split()
      new_dict = {}
      for word in rand_list:
        if word in new_dict:
          new_dict[word] += 1
        else:
          new_dict[word] = 1
      return new_dict

1 Answer

Hi Brandon,

In your for loop you're referencing rand_list rather than rand_lst which was the variable you created previously.

Also, the challenge does suggest you lowercase the string first but your code passes without it.

DOH! Thank you. I can't believe I didn't catch that, and the lower()