
Trying to learn how to code but got stuck in an infinite loop. Hard not to appreciate how it celebrates the occasion, even gives Pat Short a run for his money 22/2/22

Trying to learn how to code but got stuck in an infinite loop. Hard not to appreciate how it celebrates the occasion, even gives Pat Short a run for his money 22/2/22
4 comments
I would very much like to refractor this code. Can you tell me what you’re trying to do here OP? It looks like hangman, but the logic seems to break down in the while loop
I haven’t got a clue as to what I’m looking at, but I commend you massively for learning to code! Good luck with the studies!
In line 11, you have a loop starting `while i in copyGuess[h:-1]:`…
Two things come to mind here:
1. It’s never EVER a good idea to iterate over a variable you intend to modify
2. You never modify `copyGuess`, and `i` will be the same, set by loop in line 9. That’s your infinite loop.
That aside, you can use some python magic here and just `if i in copyGuess[h:-1]:`
WTF does any of this have to do with Ireland?