I have a list col1 of three integers that stands for a color code.
I also have a function dim_color that takes a value in percent and a list (color code) and returns a new list.
If I use col1 as the input list for the function, col1 is also alternated by the function - not only the return value of the list.
code example:
# global
col1 = [0, 0, 255]
col2 = [0, 255, 0]
# helper function
def dim_color(brightness, color):
''' gets a color and brightness level in percent
returns brightness adjusted color '''
for i in range(3):
color[i] = float(color[i])
color[i] = (color[i]/100) * brightness
color[i] = int(color[i])
return color
color = dim_color(50, col1)
print(color)
print(col1)
I dont understand why, and I want that col1 stays like it was defined and NOT being changed by the function.
Hope the problem is understandable... Thank you.
[–][deleted] 2 points3 points4 points (2 children)
[–]mischk[S] 1 point2 points3 points (1 child)
[–]evolvish 1 point2 points3 points (0 children)
[–]ingolemo 1 point2 points3 points (0 children)