9/15 scrabble_score


#1

https://discuss.codecademy.com/t/scrabble-score/249928/5
i know this can work

def scrabble_score(word):
  word = word.lower()
  total = 0
  for x in word:
    for i in score:
      if x == i:
        total = total + score[i]
  return total

but i have not idea why my code not working?
can someone help me?

def scrabble_score(word):
  total = 0
  word = word.lower()
  for key in word:
    total += score[key]
  print total

#2

If you already know that i needs to be equal to x before using it as the key, then there’s no need to look at all the i’s that aren’t equal to x, just use x immediately

Not sure what you mean by “not working”, “working” entirely avoids describing what you mean


#3

i use my code

def scrabble_score(word):
  total = 0
  word = word.lower()
  for key in word:
    total += score[key]
  print total

then output

4
7
5

and
1513408293351

does it mean i can’t use x immediately?
or something wrong


#4

What’s the difference between print and return? (both very important things, but they have very different effects)


#5

thank you!:grinning:


#6

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