def f():
list_0 = [1,2,3,4]
p = [0,1,2,3,4,5,6,7,8]
for i in list_0:
x = p
x[i] ="L"
print(x)
print(p)
f()
Wanted the result to be: 0,"L",2,3,4,5,6,7,8 , 0,1,"L",3,4...... and so on , but got , 0,"L",2,3,4,5,6,7,8 , 0,"L","L",3,4,5,6,7,8.. so one, the "L" was getting saved . How do i change the code such that the variable p does not change and remains the same