如何在Python中使用户输入不区分大小写?

如何在Python中使用户输入不区分大小写?,python,Python,我做了一个基于文字的船上冒险游戏,我发现了一个很容易意外输入错误的问题。我如何解决这个问题?这是我的密码 sleep = input("Its 11:45 what you do go to bed or stay awake till 4 am?") scenarios = ['A fish jumped on the boat and woke you up', 'You wake up needing to go to the toilet and accidentally trip an

我做了一个基于文字的船上冒险游戏,我发现了一个很容易意外输入错误的问题。我如何解决这个问题?这是我的密码

sleep = input("Its 11:45 what you do go to bed or stay awake till 4 am?")
scenarios = ['A fish jumped on the boat and woke you up', 'You wake up needing to go to the toilet and accidentally trip and fall into the ocean']
if sleep == "sleep":
    event = random.choice(scenarios)
    print(event)
if event == "A fish jumped on the boat and woke you up"
    action = input("What you do? throw it back into the ocean or catch him?")
    if action == "throw it back into the ocean":

在进行比较之前,可以将字符串转换为小写或大写

if action.lower() == "throw it back into the ocean"

哦,它给了我一个语法错误,但我解决了它是因为我谢谢你的帮助!