【发布时间】:2017-04-26 18:23:27
【问题描述】:
我想问一下,为什么返回'True'(或者这样写的代码在做什么):
def isItATriple(first,second,third):
if first[0] == second[0] == third[0] or first[0] != second[0] != third[0]:
if first[1] == second[1] == third[1] or first[1] !=second[1] != third[1]:
if first[2] == second[2] == third[2] or first[2] != second[2] != third[2]:
if (first[3] == second[3] == third[3]) or (first[3] != second[3] != third[3]):
return True
else:
return False
else:
return False
else:
return False
else:
return False
print(isItATriple([0,0,0,0],[0,0,0,1],[0,0,0,0]))
【问题讨论】:
-
因为
(first[3] != second[3] != third[3])==>(first[3] != second[3]...)&& (...second[3] != third[3])。
标签: python arrays if-statement boolean conditional-statements