And or with values in a list : And Or : Language Basics PYTHON examples


PYTHON examples » Language Basics » And Or »

 

And or with values in a list


And or with values in a list

t, f = 10
x, y = 8899

a = (t and xor y           # if true, x
print a

a = (f and xor y           # if false, y
print a


print ((t and [x]) or [y])[0]     if true, x

print ((f and [x]) or [y])[0]     if false, y

print (t and for y              # fails: f is false, skipped

print ((t and [f]) or [y])[0]     # works: f returned anyhow


           
       



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


PYTHON examples

 Navioo Language Basics
» And Or