x = [1, 2, 3]
y = x
y.append(4)
print(x)
This code will return [1, 2, 3, 4]
but I want only [1, 2, 3]
.
This works like I want it to:
x = [1, 2, 3]
y = []
y[0] = x[0]
y[1] = x[1]
y[2] = x[2]
# Or use a for loop here, instead.
y.append(4)
print(x)
Also, is there a way to get the current values of the array:
x = [foo(), bar(), someOtherChangingNumber(), datetime.now()]
# y = x's values - not the functions
print(y)