Question: OK so I want to create within a loop iterator in index that goes like this

```
[0,1,2,3,4,5,6,7,8][1,2,3,4,5,6,7,8,0][2,3,4,5,6,7,8,0,1][3,4,5,6,7,8,0,1,2]...[8,0,1,2,3,4,5,6,7]

```

where the maximum value may be 8 or another number.

so far I have some code that doesn't work.

```
a = ['l','m','n','o','p','q','r','s','t'] #len(a) = 9
b = [[]] *len(a)
c = [[]] *len(a)
for offset_index in range(len(a)):
    b[offset_index] = []
    c[offset_index] = []
    for i in range(offset_index, len(a) - offset_index, 1):
        b[offset_index].append(i)
        c[offset_index].append(a[i])
print b

```

> 
> [[0, 1, 2, 3, 4, 5, 6, 7, 8], [1, 2, 3, 4, 5, 6, 7], [2, 3, 4, 5, 6], [3, 4, 5], [4], [], [], [], []]
> 
> 
> 

I can see it's a problem with the 2nd range function, but can't imagine a neat fix.

Answer: 
Here is my code:

```
a = [1, 2, 3, 4, 5]
for slice_index in range(0, len(a)):
    print (a[slice_index::] + a[:slice_index:])

```

> 
> [1, 2, 3, 4, 5]  
> 
>  [2, 3, 4, 5, 1]  
> 
>  [3, 4, 5, 1, 2]  
> 
>  [4, 5, 1, 2, 3]  
> 
>  [5, 1, 2, 3, 4] 
> 
> 
> 

**Explanation:** `a[slice_index::]` gives the part of array where index >= slice\_index. Same for the other.
```
>>> L = ['a', 'b', 'c', 'd', 'e']
>>> [[L[i-j] for i in range(len(L))] for j in range(len(L), 0, -1)]
[['a', 'b', 'c', 'd', 'e'],
 ['b', 'c', 'd', 'e', 'a'],
 ['c', 'd', 'e', 'a', 'b'],
 ['d', 'e', 'a', 'b', 'c'],
 ['e', 'a', 'b', 'c', 'd']]

```