I know there are better ways to do this, and I found some of them online too, but I want to know why this simple logic doesn't work.
p =[0,1,2,3,4]
q = p
U = 1
for i,elt in enumerate(p):
print(p[i])
if i + U > len(p)-1:
p[(i+U)-len(p)] = q[i]
else:
p[i+U] = q[i]
print(p)
The output for this is:
0
0
0
0
0
[0, 0, 0, 0, 0]