I created the following code, where the goal is to create a different color filter for every 1/3 of a tuple list:
def color_filter(x): for i in x: for n, pix in enumerate(i): new = ((pix[0]+pix[1]+pix[2])//3, 0, 0), (0, (pix[0]+pix[1]+pix[2])//3, 0), (0, 0, (pix[0]+pix[1]+pix[2])//3) i[n] = new return x where x = [[(84, 0, 153), (84, 0, 153), (84, 0, 153)], [(177, 219, 255), (177, 219, 255), (177, 219, 255)]]
I want the code to output [[(79, 0, 0), (0, 79, 0), (0, 0, 79)], [(217, 0, 0), (0, 217, 0), (0, 0, 217)]] but it outputs [[((79, 0, 0), (0, 79, 0), (0, 0, 79)), ((79, 0, 0), (0, 79, 0), (0, 0, 79)), ((79, 0, 0), (0, 79, 0), (0, 0, 79))], [((217, 0, 0), (0, 217, 0), (0, 0, 217)), ((217, 0, 0), (0, 217, 0), (0, 0, 217)), ((217, 0, 0), (0, 217, 0), (0, 0, 217))]] instead. How can I fix this?
没有评论:
发表评论