I am working on a problem that need me rotate the numbers at index[1] in a nested loop once toward the right. The nested loop looks like this [(1, 1), (2, 2), (3, 3), (4, 4), (1, 5)] and i want the nested loop to look like this
[(1, 5), (2, 1), (3, 2), (4, 3), (1, 4)] (All the number at index[1] moved once to the right) I want to do this at a range of N times. I tried using deque from the module collections but it didn't do the thing i wanted. Here are my code.
from collections import deque
n = int(input())
a = [int(i) for i in input().split()]
s, f = map(int, input().split())
num = 0
sequence = [i for i in range(1, len(a) + 1)]
res = list(zip(a, sequence))
print(res)
for i in res:
res1 = deque(i[1])
res1.rotate(1)
print(res1)
I got an error on line 11
res1 = deque(i[1])
TypeError: 'int' object is not iterable