Pretty simple python question

Hello.

I have a list of several values, and I want to do a comparison like this:


list = [x,y,z,w]

if list = [(1 or 2), 3, (4 or 5), 0]:
    do something

The or statements are key. In this example, I would want to test if the first list value was equal to 1 OR 2, while checking the other elements of the list, using a single comparison. Unfortunately, if I just type in the code above, it ignores the value after the OR statement and just uses the first one… Typing out each list possibility is a hassle, so I want to avoid that. Thanks for any help, and let me know if I am unclear.

l = [1, 3, 5, 0]
if l[0] in (1, 2) and l[1] == 3 and l[2] in (4, 5) and l[3] == 0:
    do something

Thanks for replying. Yeah, that would work. It gets a little wordier than I would like, though, so I guess I’ll write a function to do the comparison.