Interger being decremented too much in for loop in Python
<p>This is a school project and I'm having slight trouble with one piece of the code.
This is a background:
I'm making a hangman game, and it works fine, but I'm trying to make the loop decrement an integer only if the if statement above it is false. This, seems to be a problem as it decrements the integer way too much, for example instead of 10 to 9, it decrements it from 10 to 4.
Any help is appreciated.
Here is the code:</p>

<pre><code>        # This will run when count is above 0 (the length of the word.)
    while guessesLeft &gt; 0:
        # Calls letterGuessQuery from the guessing module - gives the user the ability to guess a letter.
        guessing.letterGuessQuery(guessesLeft,guessedLetters,coveredWord)
        # Calls letterGuess from the guessing module.
        guessing.letterGuess(guessedLetters)


        # Gives the lenght of the randomWord - I use it as an index - I store in it i.
        for i in range(len(randomWord)):
            # Loops through randomWord and stores it in x
            for x in randomWord[i]:
                # Loops through the guessedLetters.
                for z in guessedLetters:
                    # If the guessed letter is equal to the letter in random word.
                    if x == z:
                        # Modifies covered word to show the correct letter.
                        coveredWord[i] = x
                    else:
                        guessesLeft -=1
</code></pre>

<p>Without seeing more of your code I would think that you are going to need a separate block that defines when the  player input is incorrect instead of trying to use the same block that defines when the player input is correct.</p>

<p>Your current block is iterating once for every letter in <code>randomWord</code> which works for the latter but not the former.</p>

<p>Separate your nesting blocks.</p>

python for-loop while-loop