如何在Python3中从两个不同的输入打印一个答案?
我是Python和stackoverflow社区的新手,在编写第一个“helloworld文件”时发现了一个特定的问题,我希望得到一些帮助 问题是我找不到从两个不同的输入字符串结果打印一个答案的方法如何在Python3中从两个不同的输入打印一个答案?,python,python-3.x,Python,Python 3.x,我是Python和stackoverflow社区的新手,在编写第一个“helloworld文件”时发现了一个特定的问题,我希望得到一些帮助 问题是我找不到从两个不同的输入字符串结果打印一个答案的方法 if information == ("Yes" or "yes") : #still trying to figure out how to make the program respond with "Ok" with both the inputs, "Yes" and "yes" print
if information == ("Yes" or "yes") : #still trying to figure out how to make the program respond with "Ok" with both the inputs, "Yes" and "yes"
print('Ok')
print('Ok')
任何帮助/答案都将非常感谢。试试这个
if information == "Yes" or information == 'yes':
希望这有帮助您可以检查是否包含:
if information in ("Yes", "yes"):
print('Ok')
或:
或
另一种方式是:
if information.lower() == "yes":
print('Ok')
print('Ok')
或者是一种懒惰的方式:
if information.lower().startwith("y"):
print('Ok')
print('Ok')
希望它能像预期的那样工作
if information in ('yes', 'Yes', 'YES'):
print('Ok')
print('Ok')
if information.lower() == "yes":
print('Ok')
print('Ok')
if information.lower().startwith("y"):
print('Ok')
print('Ok')