I want to compare two lists of the same length by their elements with an OR.
>>> [0,0,1,1,0] or [1,1,0,1,0]
[0, 0, 1, 1, 0]
I want the outcome to be
[1,1,1,1,0]
How can I achieve the desired comparison?
I want to compare two lists of the same length by their elements with an OR.
>>> [0,0,1,1,0] or [1,1,0,1,0]
[0, 0, 1, 1, 0]
I want the outcome to be
[1,1,1,1,0]
How can I achieve the desired comparison?
You can use
zip()function is used to iterate over corresponding elements of both lists simultaneously, and then a list comprehension is used to perform theORoperation on each pair of elements.Output: