15.9 Why is my code not working?


I keep getting "Does your scrabble_score function take exactly one argument (a string)? Your code threw a "object of type 'builtin_function_or_method' has no len()" error."

Can anyone explain? I would be grateful.

score = {"a": 1, "c": 3, "b": 3, "e": 1, "d": 2, "g": 2, 
         "f": 4, "i": 1, "h": 4, "k": 5, "j": 8, "m": 3, 
         "l": 1, "o": 1, "n": 1, "q": 10, "p": 3, "s": 1, 
         "r": 1, "u": 1, "t": 1, "w": 4, "v": 4, "y": 4, 
         "x": 8, "z": 10}

def scrabble_score(word):
    word= word.lower
    lent= len(word)
    for letter in word:
        while letter in score and len>0:
    return total


Hi, @tangomango9 ,

What is being assigned to word here? ...

word= word.lower


Oh I didn't catch that for some reason. I deleted the

and got an infinite loop as a result. It appears the length of the word isn't properly subtracting.


Did you change this line ...

word= word.lower

... to this? ...


If so, what is that line intended to do?


Yah I did. I thought that would make whatever word I inputted turn into lowercase.


See the documentation for str.lower(). It is a method that does not change the str object on which it is called. However, since it does return a copy of the str in lower case, you can assign the result of calling the method to the variable. Note that a method call must include parentheses. Therefore, you need to do this ...

word = word.lower()

After that correction is made, there may be additional problems to correct.


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