def shift_matrix(a):
    start_row=0
    start_col=0
    end_row=len(a[0])-1
    end_col=len(a)-1
    prev=a[0][0]
    while (start_row<end_row and start_col<end_col):
        for i in range(start_col,end_col+1):
            temp=a[start_row][i]
            a[start_row][i]=prev
            prev=temp
        start_row+=1
        for i in range(start_row,end_row+1):
            temp=a[i][end_col]
            a[i][end_col]=prev
            prev=temp
        end_col-=1
        for i in range(end_col,start_col-1,-1):
            temp=a[end_row][i]
            a[end_row][i]=prev
            prev=temp
        end_row-=1
        for i in range(end_row,start_row,-1):
            temp=a[i][start_col]
            a[start_col]=prev
            prev=temp
        start_col+=1
    a[0][0] = prev

a = [[ 1, 2,   3,  4, 5],[16, 17, 18, 19, 6],
     [15, 24, 25, 20, 7],[14, 23, 22, 21, 8],
     [13, 12, 11, 10, 9]
    ]

shift_matrix(a)

for r in a:
    print(r)

**SO I WROTE THIS PROGRAM TO SHIFT ALL THE VALUES IN AN SPIRAL ARRAY BY 1.
THE ASSIGNMENT a[0][0]= prev throws an error of "'int' object does not support item assignment".
Please help me. 
Thanks in advance**

Hy, The reason you are getting this error is because you are trying to access the element a[0][0] at the end of the function and while doing the operations in the function you change the array a and at the end of the function it has this value

[14, [16, 15, 17, 18, 5], [15, 24, 25, 19, 6], [14, 22, 21, 20, 7], [12, 11, 10, 9, 8]

and as you can see it has no element a[0][0].Hope this helps.And if you need help i llsuggest go throght this article of python .

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.