如何忽略输入字符串的大小写

raj*_*77m 0 python string substring ignore-case

这是我正在学习的示例代码.我想取一个字符串(1个或多个字符)并将其与现有字符串进行比较.我想输入蓝色仍然得到答案.怎么完全忽略这个案子?谢谢.

parrot = "Norwegian Blue"

letter = input("Enter a character: ")

if letter in parrot:
    print("The letter {0} is in the Norwegian Blue".format(letter))
else:
    print("Sorry the letter is missing ")
Run Code Online (Sandbox Code Playgroud)

成功案例:

C:\PythonMasterClass>python IfProgramFlow.py  
Enter a character: Blue  
The letter Blue is in the Norwegian Blue
Run Code Online (Sandbox Code Playgroud)

对于失败的案件:

C:\PythonMasterClass>python IfProgramFlow.py  
Enter a character: blue  
Sorry the letter is missing
Run Code Online (Sandbox Code Playgroud)

我检查了其他线程将我的输入和实际文本转换为小写并进行比较,但我想要一个直接的方法.如果我有多个字符串,我不想为了这个目的将它们全部保存在小写字母中.谢谢.

Jos*_*lls 7

尝试: if letter.lower() in parrot.lower():