Hi, I cannot get my get_word_score result passed to the test_get_word_score function on Problem Set 3? It says it gets 'none' every time. I checked the current working directory and it is set to the folder where i have all of the ps3 files. My code returns the score and works properly when i test it on my own. Anyone have an idea what I am missing? Thanks!
post the code. are we supposed to guess?
ok. sorry bout that. here is the function that i wrote: def get_word_score(word, n): """ Returns the score for a word. Assumes the word is a valid word. The score for a word is the sum of the points for letters in the word multiplied by the length of the word, plus 50 points if all n letters are used on the first go. Letters are scored as in Scrabble; A is worth 1, B is worth 3, C is worth 3, D is worth 2, E is worth 1, and so on. word: string (lowercase letters) returns: int >= 0 """ score = 0 for letter in word: score = score + SCRABBLE_LETTER_VALUES[letter] if len(word) == n: score = score*len(word)+50 else: score = score*len(word) return score i have attached the file that has the test functions as well. thanks for helping.
Join our real-time social learning platform and learn together with your friends!