나는 파이썬 2.6.6을 사용하고있다간단한 동전 던지기 게임을 다시 시작하는 방법
나는 처음부터 사용자 입력을 기반으로 프로그램을 다시 시작하려고하고있다. 감사
import random
import time
print "You may press q to quit at any time"
print "You have an amount chances"
guess = 5
while True:
chance = random.choice(['heads','tails'])
person = raw_input(" heads or tails: ")
print "*You have fliped the coin"
time.sleep(1)
if person == 'q':
print " Nooo!"
if person == 'q':
break
if person == chance:
print "correct"
elif person != chance:
print "Incorrect"
guess -=1
if guess == 0:
a = raw_input(" Play again? ")
if a == 'n':
break
if a == 'y':
continue
#Figure out how to restart program
는 내가 계속 문에 대한 혼란 스러워요. 계속 사용하면 'y'를 처음 입력 한 후에 '계속 재생'옵션이 표시되지 않으므로
다시 시작 하시겠습니까? 전체 애플리케이션을 다시 시작하거나 사용자에게 다른 동전을 던지라고 요청하십시오. – alexn
좋은 지적입니다. – user225312
따라서 전체 응용 프로그램을 다시 시작하십시오. "처음부터" – Tarrant