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 trialmauricio almonte
1,913 Pointsword count is not working in treehouse but it works on my terminal
def word_count(gotcha):
gotcha = gotcha.lower().split()
tu = []
ta = gotcha
sq = 0
do = []
total = []
dic = {}
for i in range(0,len(gotcha)):
sq = 0
do = []
while sq < len(gotcha):
if gotcha[i] == ta[sq] and gotcha[i] not in tu:
do.append(gotcha[i])
tu.append(gotcha[i])
sq += 1
elif gotcha[i] == ta[sq] and gotcha[i] in tu:
do.append(gotcha[i])
sq += 1
elif gotcha[i] != ta[sq]:
sq += 1
while sq == len(gotcha):
dic[gotcha[i]] = len(do)
if gotcha[i] + str(len(do)) not in total:
total.append(gotcha[i] + str(len(do)))
sq += 1
return dic
wordcount = word_count("I DO not like it SAM I AM") ```
1 Answer
Chris Freeman
Treehouse Moderator 68,441 PointsIt passes the challenge... if you remove the last line: wordcount = word_count("I DO not like it SAM I AM") ```
mauricio almonte
1,913 Pointsmauricio almonte
1,913 Pointsthanks sir!!