Is there any way to compare the list elements and return the outcome value ? Below is the python snippet, where it recieves two values and returns the value.
def logical_or_decision(a,b):
return a or b
value = logical_or_decision(1,0)
print value
I need to make it generic & scalable to more than 2 elements.How can i do it for more than 2 elements ?
There's a built-in function that does this: any
.
>>> any([0,0,1,0])
True
>>> any([0,0,0])
False
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With