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!
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.
For debugging, try printing hand as part of each iteration. Dollar says it's not what you expect.
Join our real-time social learning platform and learn together with your friends!