代码 'for' 'in' 'not in' 不工作,如何修复以尊重命令之前给出的答案?

Code 'for' 'in' 'not in' not working, how to fix so it respects answers give prior to commands?

我一直在尝试制作一个简单的小游戏,您可以在其中行走并找到不同的东西,但出于某种原因,当我键入 for 和 in 命令时,它不尊重 b[ 中的答案=20=]

#
print('You may now begin your quest because I said so')
print('You must choose a number between 1 and 10, each number must be selected only once')
a = int(input('How many block do you wanna walk?'))
if a == 1:
    print('Really? 1 block? LUL')
if a == 2:
    b = str(input("You've found a hole, it is too dark too see what's on it though, do you wish to explore?"))
    hang = ("yes")
for b in hang:
    print('You fell and died.')
else:
    print('Ok then, keep going.')

如您所见,它非常简单,但它始终同时显示 for b in hang:else 我确实尝试创建另一个列表 fk = ("no") 并更改 else for for b in fk: print('Ok then, keep going') 但它也不起作用,我也尝试放置 for b not in hang: print('Ok then, keep going') 但梯子根本不起作用

仅通过阅读您的代码,您似乎正在迭代字母 yes

你到底想做什么?

如果 hang 应该是元组,请尝试向其添加 ,

hang = ('yes',) 

if b in hang:
    print('You fell and died.')
else:
    print('Ok then, keep going.')

你可以试试:

if b.startswith('y'):
    print('you fell and died')