xs = [1,2,3,4]
ys = [10,20,30,40]
for x in zip(xs,ys):
print(x)
(1, 10) (2, 20) (3, 30) (4, 40)
[1,2,3,4,5]
rotate right by 3 positions
[3,4,5,1,2]
s = [1,2,3,4,5]
s[3:] + s[:3]
[4, 5, 1, 2, 3]
def rotate(n,s):
return s[n:] + s[:n]
rotate(3,[1,2,3,4,5])
[4, 5, 1, 2, 3]