Page 1 of 1

Implement negate_checkered that takes in an image in the form of a 2D list of tuples. Your function should replace all b

Posted: Mon Jun 06, 2022 5:11 pm
by answerhappygod
Implement negate_checkered that takes in an image in
the form of a 2D list of tuples. Your function should replace
all black pixels to white and all white pixels to black. Your
function should return the updated
image.
Example
Input:
Output:
This is my solution but it returns an empty list:
def negate_checkered(list):
new_list = []
for i in list:
for j in range(len(i)):
if j ==
(255,255,255):
j =
(0,0,0)
elif j == (0,0,0):
j =
(255,255,255)

new_list.append(j)
return new_list