Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

reza sajadian
718 PointsCan anybody help me with my quiz?
This is my quiz:
Create a function named word_count() that takes a string. Return a dictionary with each word in the string as the key and the number of times it appears as the value.
and this is my answer:
my_dict = {}
def word_count(string):
stn_string = string.lower()
mylist = stn_string.split()
replist = mylist[:] # replist(as of replicated list) Keeps the original listed string intact
for word in replist:
if word in my_dict:
my_dict[word] += 1
else:
my_dict[word] = 1
break
return my_dict
2 Answers

Ken Alger
Treehouse TeacherReza;
Take a look at the great answer Tree Casiano provided on this question in this post.
Hope it helps and happy coding,
Ken

reza sajadian
718 PointsThanks Ken. It was completely helpful. thumbs up.

Ken Alger
Treehouse TeacherPleased it helped and welcome to Treehouse!
Ken Alger
Treehouse TeacherKen Alger
Treehouse TeacherEdited for markdown