[Python Snippets] Python logical operation between list

Python logical operation between list

def and(x, y):
    if x:
        return y
    return x
  
def or(x, y):
    if x:
        return x
    return y
a = ['ABAR 200', 'CDXE 500', 'BKWR 250', 'BTSQ 890', 'DRTY 600']
b = ['A', 'B']

>> a and b
>> ['A', 'B']

>> a or b
>> ['ABAR 200', 'CDXE 500', 'BKWR 250', 'BTSQ 890', 'DRTY 600']

출처

https://stackoverflow.com/questions/47419342/logical-operation-between-two-boolean-lists?rq=1