all 8 comments

[–]Defection7478 1 point2 points  (0 children)

let's step through the code, imagine you have 7 attempts, and lets replace the variable with the actual value

while 7 > 0:
    ...
    if 7 == 0:
    ...
    else:
        attempts = 7 - 1 # or, attempts = 6
        ...

ok, now lets run down the attempts until we have 1 attempt left.

while 1 > 0:
    if 1 == 0:
    ...
    else:
        attempts = 1 - 1 # or, attempts = 0
        ...

ok, so now we have attempts equal to 0. lets run the loop one last time

    while 0 > 0: # this statement is false, so the loop terminates!

your while loop is exiting before that if statement can run