Below is a simplified version of my problem:
example =[
[0, 0, 0, 0, 0],
[0, 0, 0, 0, 0]
]
def func(data):
data[0][0:6] = [1, 1, 1, 1, 1]
data[1][0:6] = [1, 1, 1, 1, 1]
return data
print(example)
func(example)
print(example)
and has the output:
[[0, 0, 0, 0, 0], [0, 0, 0, 0, 0]]
[[1, 1, 1, 1, 1], [1, 1, 1, 1, 1]]
The output I am expecting is:
[[0, 0, 0, 0, 0], [0, 0, 0, 0, 0]]
[[0, 0, 0, 0, 0], [0, 0, 0, 0, 0]]
How do I avoid the global variable "example" from being updated after running "func"? I have tried a number placeholder variable combinations (inside and outside "func") and all have the same result - an updated "example".