scrabble_score


#1

what does the statement 'for key in char' mean?

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


#2

Here is my code

def scrabble_score(word):
	result = 0
	for c in word:
		result += score[c.lower()]
	return result

#3

Your code is amazing - concise and very pythonic! But could you explain why 'return total' is not indented?


#4

If your message's about code by @terrence0010 "return result" is not intended, because we don't need result after each iteration of for-loop. We need result only after for-loop is ended and variable "result" literally contains result.