在这段代码中,当任何一个问题得到解答时,它会再次询问它,然后才会返回结果。如果它问你,你拿起棍子吗? (输入Y或N)你回答Y它会再次提示问题。我正在寻找一个解决方案,任何想法?有问题的功能是choice1
# Project
# Created By: Misha
import time
import random
weapon = 0
def intro():
time.sleep(3)
print "You wake up."
time.sleep(1)
print "..."
time.sleep(1)
print "You are surrounded by white tiled walls and floors"
time.sleep(2)
print "You do not remember anything"
time.sleep(1)
print "Ahead of you are two doors."
time.sleep(2)
print "One leads to the left and the other to the right"
print ""
def choose_door1():
chosen_door1 = ""
while chosen_door1 != "L" and chosen_door1 != "R":
time.sleep(2)
chosen_door1 = raw_input("Which door do you take? (input L or R)")
return chosen_door1
def proceed_1(chosen_door1):
if chosen_door1 == "L":
time.sleep(2)
print "You head through the left door"
time.sleep(2)
print "There is a stick lying on the ground"
time.sleep(2)
elif chosen_door1 == "R":
time.sleep(2)
print "You head through the right door"
time.sleep(2)
print "There is a keypad on the wall"
def choice1(chosen_door1):
if chosen_door1 == "L":
choice_left1 = ""
while choice_left1 != 'Y' and choice_left1 != 'N':
time.sleep(2)
print ""
choice_left1 = raw_input("Do you pick up the stick? (input Y or N)")
return choice_left1
elif chosen_door1 == "R":
choice_right1 = ""
while choice_right1 != 'Y' and choice_right1 != 'N':
time.sleep(2)
print ""
choice_right1 = raw_input("Do you input anything in the keypad? (input Y or N)")
return choice_right1
def action_left1(choice_left1):
if choice_left1 == "Y":
print "You equipped the Stick!"
weapon = 1
elif choice_left1 == "N":
print "You left the stick lying on the ground"
else:
print "ERROR"
def action_right1(choice_right1):
if choice_right1 == "Y":
print "You decided to input something into the keypad"
print ""
elif choice_right1 == "N":
print "You decided to not enter anything into the keypad"
time.sleep(1)
print "You went back the way you came and went into the left door"
intro()
chosen_door1 = choose_door1()
proceed_1(chosen_door1)
choice1(chosen_door1)
if chosen_door1 == "L":
action_left1(choice1(chosen_door1))
elif chosen_door1 == "R":
action_right1(choice1(chosen_door1))
答案 0 :(得分:0)
删除
if chosen_door1 == "L":
action_left1(choice1(chosen_door1))
elif chosen_door1 == "R":
action_right1(choice1(chosen_door1))
答案 1 :(得分:0)
只需删除第82行 choice1(chosen_door1)
intro()
chosen_door1 = choose_door1()
proceed_1(chosen_door1)
choice1(chosen_door1) # REMOVE THIS LINE
if chosen_door1 == "L":
action_left1(choice1(chosen_door1))
elif chosen_door1 == "R":
action_right1(choice1(chosen_door1))