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

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

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

Post 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
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply