i used nested 'and' condition in python 'if statement' below,
a=[3.93, 3.90, 3.92, 3.91] if (a[0] , a[1])==3.90 , (a[2] , a[3])==3.91: print(true) else: print(false) while executing code produces result 'true'.
but needs produce 'false' since a[2] , a[3] not equal 3.91 a[0] , a[1] not equal 3.90.
may know reason , correct code?
unfortunately, programming languages require more precision english language. want, this:
if a[0] == 3.90 , a[1] == 3.90 , a[2] == 3.91 , a[3]==3.91: the code started going "truthy" test on (for example) a[0] , a[1] – and return a[1] since both "true". therefore, (a[0] , a[1]) 3.90. so, first part of conditional evaluates true – , same reason, second part.
Comments
Post a Comment