Scrabble_score find an error?


What's wrong with this code? I'm trying to find exactly why this doesn't work?

def scrabble_score(word):
    for i in inp:
        while vo>0:


For the exercise scrabble score in Python, there are certain scores for certain numbers, as is provided in the dictionary at the top of the code. You have to use this dictionary to add together the total scrabble score of the word.

Barry Allen


@bartholomewallen, pretty sure he has the dictionary, where else does score refers to?

Why do you have two loops? it looks confusing, you just need one to loop over the letters of your word and add the points to count.

I would place count outside the loop in that case, since otherwise you score gets reset each time


I get what you mean.

def scrabble_score(word):
result = 0
for char in word.lower():
result += score[char]
return result
this code works, but I don't get why it considers every letter and then stops while my code takes into account only the first letter?
Thanks btw!


@stetim94, you are very right, of course. And @microcoder01837 you can also replace the while loop with a for loop iterating over the length of inp, instead of having to assign another variable just holding the length.

Barry Allen


you want to have points for all your letters? Otherwise you are going to lose this scrabble game, why should it stop after the first letter?


I understand the rules, I'm asking why my original code does not add every letter's point to the count?


@microcoder01837, your original code doesn't take into account every letter's point because you are resetting your count variable in every iteration So the value it returns is just the last letter's scrabble score. Hope this clears things out for you...

Barry Allen


It does. I guess I overthink lol. THank you!