Quantcast

Got Homework?

Connect with other students for help. It's a free community.

  • across
    MIT Grad Student
    Online now
  • laura*
    Helped 1,000 students
    Online now
  • Hero
    College Math Guru
    Online now

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

tcc8m Group Title

Question on PS3 #4. I have run into an issue with the first part of my play_hand function. I was successful running the harness test functions for the first 3 functions. When I run the code (pasted in the link below) and enter an invalid word, I cannot escape the "if not... " part of the function. I know that my solution is not correct but I want to know why I can't escape the "if not..." part of the function when I enter an invalid word. I am not as concerned with the solution to the actual problem #4. http://pastebin.com/RjU6Y4QF

  • one year ago
  • one year ago

  • This Question is Closed
  1. tcc8m Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    Just to clarify. My problem is that when I enter an invalid word, I get prompted to enter a new word. Ok so far so good. But even if that new word is valid, the error message about entering an invalid word is returned. In other words I can't enter a valid word if I first enter an invalid one.

    • one year ago
  2. bwCA Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    i'm getting a sytax error for the break - i is not 'in' a loop i commented out the break and it worked for me http://dpaste.com/802363/

    • one year ago
  3. tcc8m Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    I tried taking out the break and here is the result that I got: http://pastebin.com/Ff1Z00UJ So when I enter an invalid word, those letters are removed from the hand and I can't use them to make a new valid word. I don't know why this is happening. My get_word_score, update_hand, and valid_word functions all passed their harness tests. Can anyone provide any insight as to why this is happening?

    • one year ago
  4. Dr.Ew Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    A few things to consider: 1. include all the code, so we don't have to hunt 2. play_hand isn't returning anything, maybe it should? 3. an if should generally have a else statement 4. its probable that is_valid_word never returns True

    • one year ago
  5. bwCA Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    i put your play_hand() function into my ps3 solution and i did not experience the symptom you described. i gave it several invalid words and it did not remove any letters from hand. I don't see how that could possbly happen with the code from your original post - that function does not do anything other than ask for a word over and over till it gets a valid word then just stops - http://dpaste.com/803364/

    • one year ago
  6. msmithhnova Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    I had this same problem originally. The test harness will pass but when you implement play_hand the "hand" gets mutated when you send it to "is_valid_word" so you need to use something like "temp_hand=hand.copy()" at the start of your "play_hand" and send "temp_hand" instead of "hand".

    • one year ago
  7. tcc8m Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    Msmithhnova I think you are probably correct. However I am still having trouble. I just looked at the solution code for PS3 and I am having trouble running #4.

    • one year ago
  8. msmithhnova Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    What is it doing or not doing? Also, it would likely be easiest to assist you if you were to post your ps3a.py on one of the code sites.

    • one year ago
    • Attachments:

See more questions >>>

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.