Quantcast

A community for students. Sign up today!

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

LoveMathFermat

  • 2 years ago

Hi! Could you guys look at my code for problem #2: Update a hand in a word game. def update_hand(hand, word): for letters in word: hand[letters]=hand[letters]-1 return hand This code doesn't work for some cases. For instance, I have {s e e a} in my hand and I typed 'sea' which also deletes extra 'e' that I had. Can you guys explain what I am thinking wrong conceptually and how it should be fixed? Thank you!

  • This Question is Closed
  1. TuringTest
    • 2 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    I have the almost exact same code as you for that problem, so perhaps your bug lies in another function. The only difference is that I clone the hand for the replay part later on. newHand=hand.copy() but I don't think that should cause the effect you are dealing with.

  2. rsmith6559
    • 2 years ago
    Best Response
    You've already chosen the best response.
    Medals 1

    For debugging, try printing hand as part of each iteration. Dollar says it's not what you expect.

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