scenario2(outcome)函数调用sget\u choice3 one,以便根据用户的选择打印结果。你知道吗
如果用户选择为0,我希望函数循环并请求输入两次(正确的选择是1,0只是它的一个分支)。你知道吗
s2option_list3 =['Try to force it', 'Examine the door']
def sget_choice3(s2option_list3):
i = -1
while i <= 0:
print s2option_list3
choice3 = raw_input("> ")
for i, opt in enumerate(s2option_list3):
if opt in choice3:
i = i + 1
return i
else:
i = i + 2
return i
print "You need to select one of the given actions"
def scenario2_exit(outcome):
print outcome
choice = outcomes[0]
if outcome in choice:
print "conversation"
res3 = sget_choice3(s2option_list3)
if res3 == 0:
print "You try to force it but without any luck. However you do notice a little button on the left corner. "
else:
print "A small panel comes out, seems to be requesting a code. "
print "conversation"
else:
print "conversation"
您的问题似乎在这一行:
当您像那样使用
enumerate
时,它会用枚举的索引覆盖i
(-1
的值(第一个选项是0
,第二个选项是1
)。我不知道你为什么要使用枚举。你知道吗在不给你太多关于如何重组你的程序的建议的情况下,一个简单的解决方案可以是:
相关问题 更多 >
编程相关推荐