好的,所以我正在制作一个基于文本的冒险,我已经介绍了变量金。我正试图在其中一个故事选项中做到这一点,你可以选择捡起金币。我的语法如下所示:
if choice == "A":
print("There is no answer. But there is 5 gold on the floor, would you like to pick it up? Type: YES or NO")
yesorno = input()
if yesorno == "YES":
g = g + 5
print("You picked them up.",ge,"g")
elif choice == "B":
print("Someone from a long distance away shouts: 'Shut up",name,"!'. Then the man walks away down what seems like a echoey corridor.")
elif choice == "C":
print("Nothing happens, you are left to die.")
sys.exit("You lost")
选择“A”可以正常工作,但如果我想选择 B 或 CI,则必须输入两次,如下所示:
Either type A, B or C to choose.
B
B
Someone from a long distance away shouts: 'Shut up g !'. Then the man walks away down what seems like a echoey corridor.