anonymous
  • anonymous
Problem 3: scrabble The function for checking whether a word is valid passes the test provided: if word in word_list: for k in range(0,len(word)-1): if (word[k] in hand.keys()) & (word.count(word[k]) <= hand.get(word[k])): return True else: return False The main code seems to not implement correctly: if not is_valid_word(word, hand, wordlist): word = raw_input("Enter word, or a '.' to indicate that you are finished: ") if word == '.': print "Your total score is: " + str(score) any ideas?
MIT 6.00 Intro Computer Science (OCW)
  • Stacey Warren - Expert brainly.com
Hey! We 've verified this expert answer for you, click below to unlock the details :)
SOLVED
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.
schrodinger
  • schrodinger
I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!
anonymous
  • anonymous
added the following under for loop if word[k] not in hand.keys(): return False That seems to fix it, but the function passes the test without it, so I think the test should include situations where the word contains letters that are not in the hand.

Looking for something else?

Not the answer you are looking for? Search for more explanations.