Quantcast

A community for students. Sign up today!

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

magnitude

  • one year ago

I am having trouble implementing "play previous hand" in the Word Game problem. When the player enters "r" for "replay", the game displays, instead of the original hand, the hand with letters missing. I think there is a side-effect going on in my update_hand function, and i don't know how to identify or fix it. Here is the relevant code. Thanks! http://dpaste.com/1046521/

  • This Question is Open
  1. bwCA
    • one year ago
    Best Response
    You've already chosen the best response.
    Medals 2

    2008 or 2011? update_hand is not supposed to mutate hand - yours does however, the symptom you describe is is caused elsewhere - where does hand come from?

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

    2011. I changed my update_hand first copying hand http://dpaste.com/1047548/ By not mutating the hand, I am able to use replay correctly. I am a little confused why this happened. Why is it that when I set hand = updated_hand inside play_hand it effects the hand in play_game() only when hand is mutated? Is it because when hand is created in play_game it points to the full hand. Then in play_hand, hand eventually points to a new value equal to updated_hand. Thus, when play_hand ends, hand points what it did originally in play_hand?

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

    http://docs.python.org/2/reference/datamodel.html#objects-values-and-types

  4. 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.