0
플레이어 1이 마지막 플래그를 사용하면 끝내기를 원하지만 플레이어 2에게 요청하면 종료되지 않습니다.파이썬에서 while 루프를 종료하는 방법?
while (flags>0):
print "There are",flags,"flags left."
print "Next player is 1"
selection=input("Please enter the number of flags you wish to take: ")
if (selection<1)or (selection>3):
print "You may only take 1, 2 or 3 flags."
selection=input("Please enter the number of flags you wish to take: ")
else:
flags=flags-selection
print "There are",flags,"flags left."
print "Next player is 2"
selection=input("Please enter the number of flags you wish to take: ")
if (selection<1)or (selection>3):
print "You may only take 1, 2 or 3 flags."
selection=input("Please enter the number of flags you wish to take: ")
else:
flags=flags-selection
else:
if (flags<0) or (flags==0):
print "You are the winner!"
코드의 마지막 부분에 플래그에 대한 검사가 다른 문에 야해 – Craicerjack