Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在Python3中从两个不同的输入打印一个答案?_Python_Python 3.x - Fatal编程技术网

如何在Python3中从两个不同的输入打印一个答案?

如何在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

我是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('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')