def shift(lst):
lst2 = lst
for i in range(len(lst)):
lst[i] = lst2[i-1]
return lst
def main():
lst = [1,2,3,4,5]
print(lst)
print(shift(lst))
main()
This prints: lst = [1,2,3,4,5] lst2 = [5,5,5,5,5]
I'm trying to shift the values of list backwards by one step but every time it ends up changing both lists(lst,lst2) instead of only the original list(lst) why is that?