Ask your own question, for FREE!
MIT 6.00 Intro Computer Science (OCW) 16 Online
OpenStudy (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?

OpenStudy (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.

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!