파이썬으로 새롭게 태어나서 텍스트 모험을하고 함수 사용을 테스트합니다.함수를 호출하지 않고 함수를 호출했습니다.
def cell1():
loop = 1
while loop == 1:
print("ONE")
cave1 = input()
if cave1 == ("end?"):
print("\nthis should end program")
loop = 0
break
elif cave1 == ("TWO"):
global testvar
testvar = 1
option1()
else:
print("INVALID")
def option1():
print("TWO")
loop = 1
while loop == 1:
print("test1 definition")
print (testvar)
test1 = input()
if test1 == ("ONE"):
print("you pick up the cheese")
loop = 0
cell1()
elif test1 == ("THREE"):
option2()
else:
print("INVALID")
def option2():
print("THREE")
loop = 1
while loop == 1:
print("This is option 3")
test2 = input()
if test2 == ("ONE"):
print("testering2")
cell1()
elif test2 == ("TWO"):
global testvar
testvar = 2014
option1()
else:
print("INVALID")
run = True
while run == (True):
print ("testing 123")
cell1()
print("restart about to activate")
cont = input("Restart? ")
if (cont) != "yes":
break
이 프로그램은 옵션 사이를 이동합니다 (객실 어떻게 될지) 결국 CELL1에, 프로그램이 종료 할 수 있어야합니다 허용해야합니다.
프로그램이 실행 중이고 "종료?" 첫 번째 입력으로 입력 된 경우 프로그램은 하단의 계속 비트로 이동합니다. 그러나 'rooms'사이를 이동 한 다음 cell1로 돌아가서 'end?'를 입력하면
Ive는 주위를 둘러 보았고 아직도 나를 괴롭 히고 있습니다. 나는 잘못된 것입니까?
도움을 주시면 감사하겠습니다.
힌트 : CELL1는 옵션 1을 호출하고, 옵션 1은 CELL1을 호출하고 CELL1 단부 옵션 1은 제 끝나면 cell1 호출은 계속 실행 중입니다. – Kevin