0

I am making a simple python game. I would like to be able to restart the game based on user input. You have a certain amount of guesses to guess which way to coin falls. If you lose you would get the option of restarting, instead of just breaking the code. Also the program will not print "you lose". And I can not figure out why.
Thanks

import random
import sys
import os

print "You may press q to quit at any time"
print "You have six chances"
guess = 5
while guess >= 0:
    chance = random.choice(['heads','tails'])
    person = raw_input(" heads or tails: ")
    
    if person == 'q':
         print " Nooo!"
    if person == 'q':
        break   
    if person == chance:
        print "correct"
    elif person != chance:
        print "Incorrect"
        guess -=1
    elif guess == 0:
        print "you lose"
        break

Edited by raden1: n/a

2
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by ultimatebuster
0

Never mind, for I have learned of the continue statement.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.