Quantcast

A community for students. Sign up today!

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

shawnf

  • one year ago

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?

  • This Question is Closed
  1. shawnf
    • one year ago
    Best Response
    You've already chosen the best response.
    Medals 0

    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.

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

    • Attachments:

Ask your own question

Ask a Question
Find more explanations on OpenStudy

Your question is ready. Sign up for free to start getting answers.

spraguer (Moderator)
5 → View Detailed Profile

is replying to Can someone tell me what button the professor is hitting...

23

  • Teamwork 19 Teammate
  • Problem Solving 19 Hero
  • You have blocked this person.
  • ✔ You're a fan Checking fan status...

Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.

This is the testimonial you wrote.
You haven't written a testimonial for Owlfred.