[英]If statement that only satisfies when both conditions are met - Python
I'm trying to figure out the issue with this code.我试图找出这段代码的问题。 I'm coding in python.我正在用python编码。 I want my condition to fail only when both statements are inside an array.我希望我的条件仅在两个语句都在数组中时才失败。 Otherwise, I'm looking for this code to pass and print "Enter".否则,我正在寻找此代码以通过并打印“Enter”。
edge1 = []
edge2 = []
edge1.append("hello")
edge2.append("world")
if ("hello" not in edge1 and "bye" not in edge2):
print("entered")
Expected output: "entered"预期输出:“进入”
Since you said, "I want my condition to fail only when both statements are inside an array."既然你说,“我希望我的条件只有当两个语句都在一个数组中时才会失败。”
Your 'if' condition should be like following您的“如果”条件应如下所示
if (not ( "hello" in edge1 and "bye" in edge2)):
print("entered")
ie 'not' should be applied to the final outcome即“不是”应该应用于最终结果
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.