I'm stuck in ps3. I've got the components to pass the test functions. But when I try to get the hand to play IDLE says:
raceback (most recent call last):
File "", line 1, in
play_hand(word_list)
File "/Users/Noel/Documents/Professional Development/MIT CS 6.0/PS3/ps3a.py", line 247, in play_hand
while len(hand) > 0:
UnboundLocalError: local variable 'hand' referenced before assignment
I've tried to use global in the parts above for hand, but this doesn't seem to resolve the problem. Is there a way I can attach my .py file so people can see?
Still Need Help?
Join the QuestionCove community and study together with friends!
Sign Up
OpenStudy (anonymous):
OpenStudy (anonymous):
You have no variable in the play_hand function called hand. I believe you want hand = deal_hand(n), not just deal_hand(n) (and, actually...for that matter, what is n?).
OpenStudy (anonymous):
Thank you so much for your help! Yes, I have changed that so that hand is defined as the result of deal_hand. I used (n) instead of HAND_SIZE I should go through the entire program and switch that over.
So, we have resolved the error. But now I have a problem with the update_hand function and the get_word_score part as well, since the score remains at zero and the keys whose values are zero are not being trimmed from the dictionary as I hoped they would be.
I'll attach what I have at the moment. Thank you for your help.