我是Python的初学者。作为尝试和学习的一步 我现在正在创建一个故事类游戏。如何检查python中的输入答案3
所以我想检查用户是否输入了有效的输入。
print("You see two roads, one to the left and one to the right...\n")
time.sleep(1)
answer = input("Do you want to go left or right?[Valid answer is yes/no\n").lower
if answer == "yes" :
print("You start to walk left")
else:
print("You end your journey here, thanks for playing")
quit()
好了,所以基本上只检查我来到这里是如果用户键入yes或no,但如果什么类型的用户别的东西? 然后,我会喜欢有一个选项,打印出“请输入是或否”,然后再次向用户发送同样的问题?
对不起,如果我不能很好地回答这个问题,英语不是我的母语。
我很抱歉,但做了一个搜索,发现什么都不适合。 :) –
我不认为这是重复的。 – Josh
@Josh - 这是一个完美的重复。你为什么不相信? – TigerhawkT3