Oops, try again. Your function fails on scrabble_score("pie"). It returns "None" when it should return "5".

Hi, please share why this is not working. Thanks a ton.

def scrabble_score(word):
    total = []
    word = raw_input("Enter a word.").lower()
    for i in str(word):
        if i in score:
            total += score
        return total


if you want to prompt the user for a word, do this outside the function and supply the user input as argument when calling the function

A function ends the moment a return keyword is reached, if a return keyword is reached in a loop, the loop breaks


How to supply the user input as argument?


After the function, you prompt the user using raw_input. You store the result of the prompt in a variable, then you call the function and supply this variable as argument

If you are clever, use .isalpha() (which you also used in pyglatin) to validate the users input is valid


Okay thanks, are there cases when it would be wiser to it after the function than before?


it? What is it? the prompt? The function call?

we are currently adding it (whatever it is) after the function?


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