来自sys import exit
def start():
print "You woke up in a dungeon"
print "There is three weapon in front of you"
print "A sword, a staff and dagger"
print "Which one do you choose"
choice = raw_input("")
if choice == "dagger":
print "A rogue huh?"
elif choice == "staff":
print "A wizard how interesting..."
elif choice == "sword":
print "A warrior."
else:
print "..."
dungeon_path()
def dungeon_path():
if choice == "dagger":
print "Which way you choose rogue"
start()
如果我在第一个功能中选择了匕首,我想要打印最后一行但是我似乎无法让它工作我试图给出一个值,然后使用"如果"但它也没那么奏效,所以我该做什么......
答案 0 :(得分:1)
您可以将choice
变量作为参数传递给dungeon_path
函数:
...
print "..."
dungeon_path(choice)
def dungeon_path(choice):
if choice == "dagger":
print "Which way you choose rogue"