# Giving user extra guesses?

#1

This is beyond the scope of the particular lesson, but I am curious:

How could I give the user an extra guess, say if they guess the same variable twice?

I tried simply setting my counting variable back by 1 each time this happens:

``````        elif(board[guess_row][guess_col] == "X"):
print "You guessed that one already."
i -= i``````

This seems to work for the turn counting (says "Turn 1" over and over), but it still only gives the user 4 total guesses. How would I actually reset the "for" counter?

#2

Like so,

``````turns = 0
while turns <= 5:
# Do Stuff
if guess_correct:
turn += 1
elif guess_wrong:
turn += 1
elif guess_again:
turn -= 1``````

Just like that, albeit you can make it more consice,

``````def play(turn=0):
while turn <= 5:
if guess_again:
turn -= 1
# ect...``````

You could also check like this though,

``````ship_coord = (1, 1)
guess_previous = [(2, 2), (5,5)]
guess_row = 1
guess_col = 1
turn = (turn - 1) if (guess_row, guess_col) in guess_previous else (turn + 1)``````

There are a plethora of different ways to do this but in general you will want to use a while too to archive this and then add subtract.

You would be unable to use a for loop because of scope issues.

#3

Ah, thank you!

Haven't gotten to "while" loops, so that explains it.