2 回答
TA贡献1780条经验 获得超5个赞
当你像那样链接它们时你需要使用elif语句,否则输入'i',if你拥有的第三条语句将为假并运行相关else语句:
## inventory var ##
inv=["torch"]
## inventory function ##
def ichk():
print(f" You are carrying{inv}")
return
##First room, links to a3##
def a2():
move=input("placeholder text.. You notice an exit to your 'east': ")
if move==("e"):
print("You exit to the east")
a3()
elif move==("i"):
ichk()
elif move==("q"):
print("You find nothing of value")
a2()
else:
print("You can't move in that direction")
a2()
TA贡献2080条经验 获得超4个赞
在Python中,如果有多个条件语句,需要写成:if,elif,elif,elif,....,else
## inventory var ##
inv=["torch"]
## inventory function ##
def ichk():
print(f" You are carrying{inv}")
return
##First room, links to a3##
def a2():
move=input("placeholder text.. You notice an exit to your 'east': ")
if move==("e"):
print("You exit to the east")
a3()
elif move==("i"):
ichk()
elif move==("q"):
print("You find nothing of value")
a2()
else:
print("You can't move in that direction")
a2()
添加回答
举报