'if any value in (x, x, x) is bellow x [duplicate]

How can I do a check to see if the value of whatever is in (x, x, x) is below for example 5

for i in range(img.size[0]):  # for every pixel:
    for j in range(img.size[1]):
        if pixels[i,j] != (0, 0, 0) and (1, 0, 0) and (0, 1, 0) and (0, 0, 1) and (1, 1, 0) and (0, 1, 1) and (1, 0, 1) and (1, 1, 1) and (1, 1, 2) and (1, 2, 1) and (2, 1, 1) and (2, 2, 1) and (1, 2, 2) and (2, 1, 2) and (2, 2 ,2):  # if not black:
            pixels[i,j] = (255, 255, 255)  # change to white


Solution 1:[1]

Just check your components by iterating over the tuple:

...
if not any(value <= 5 for value in pixels[i,j]):
...

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Netwave