Code that makes cyclic reference for x spaces in list
<p>I have a tasko to make a program in which i get m, n and k. I should create a list a with <code>n*m</code> element.
List <code>b</code> is supposed to have <code>n*m</code> element. It is created from list a with cyclic shift k to the right for m elements of lists. 
I know it is poorly explained. Example is:</p>

<pre><code>n=3
m=4
A=1 2 3 4 5 6 7 8 9 10 11 12
k=1
B=4 1 2 3 8 5 6 7 12 9 10 11
</code></pre>

<p>What i have at the moment is:</p>

<pre><code>from random import randint
n = int(input())
m=int(input())

A = []
B=[0]
B=B*n*m
for i in range(n*m):
    A = A + [randint(1, 30)]

print('\nLista A:\n')
for i in range(n*m):
    print(A[i], end = ' ')

print()

k=int(input())

for i in range(-1, m*n, m):
    B[m-1-i]=A[i]
    print(B[m-1-i])

print('\nLista B:\n')
for i in range(n*m):
    print(B[i], end = ' ')
</code></pre>

<p>Thanks</p>

<p>Try this... </p>

<pre><code># Start with an empty list
B = []
# Take A in chunks of m
for i in range( int(len(A)/m) ):
    # Take an m-sized chunk of A
    chunk = A[m*i:m*(i+1)]
    # Shift it to the right by k (python style!)
    shift = chunk[-k:] + chunk[:-k]
    # Add it to B
    B += shift
print (B)
</code></pre>

python list cyclic-reference