9/15 - scrabble


#1
def scrabble_score(word):
  word = word.lower()
  total_score = 0
  for letter in word:
    total_score = total_score + score[letter]
  return total_score

Hello, I feel really dumb but no matter what i can’t figure out why this code doesn’t work. Somebody be so kind and explain it to me please.


#2

May we assume that the score dictionary is in place?


#3

Yeah, the ‘score’ dictionary is given in the excerscise. It’s the whole alphabet.


#4

Can you please link to the exercise so we can test your code and see if the error is replicatable.


#5

https://www.codecademy.com/courses/learn-python/lessons/practice-makes-perfect/exercises/scrabblescore?action=lesson_resume

^^ Hopefully linking like this works


#6

As expected, the code works. Is the SCT not accepting the submitted code?


#7

In the lower bottom of the screen it was giving me the error “with your code pie = 3 when it should be 5” or something like that (already got the code from the program for the excercise and skipped it).


#8

That’s odd. It returns 5 in my test. Did you do anything to modify the dictionary, perhaps?


#9

No, definitely not. Though i went back now, reset the excercise and input my code and it worked. Well, no idea what happend before (I’m 99% positive i haven’t modified the dictionary in any way and input the code exactly as it’s here). But hey, thanks for the help nonetheless and sorry to waste your time!


#10

No problem. Always a pleasure.


#12

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.