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.
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 :)
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.
I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!
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.
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
I tried taking out the break and here is the result that I got:
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?
Not the answer you are looking for? Search for more explanations.
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
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/
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".
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.
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.