Scrabble


#1



https://www.codecademy.com/courses/python-intermediate-en-rCQKw/1/3?curriculum_id=4f89dab3d788890003000096#


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


#2

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


#3

How to supply the user input as argument?


#4

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


#5

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


#6

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

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


#7

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