0

The program given in the description does not give me the correct execution. Can you please help me to find it out?

Given a square matrix mat[][] and a number k. The task is to shift first k elements of each row in the right of the matrix. # Python3 program to shift k # elements in a matrix. N = 4 # Function to shift first k # elements of each row of # matrix. def shiftMatrixByK(mat, k): if (k > N) : print ("shifting is" " not possible") return j = 0 while (j < N) : # Print elements from # index k for i in range(k, N): print ("{} " . format(mat[j][i]), end="") # Print elements before # index k for i in range(0, k): print ("{} " . format(mat[j][i]), end="") print ("") j = j + 1 # Driver code mat = [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]] k = 2 # Function call shiftMatrixByK(mat, k) # This code is contributed by # Manish Shaw (manishshaw1)

10th Aug 2019, 3:39 PM
Deepikasri Kumarappan
Deepikasri Kumarappan - avatar
1 Respuesta
0
I'm sorry but I run your code and it seems like it's working, maybe I didn't get what you meant. Could you check it or explain in a more detailed way what you wanted it to do? It could be a version thing also, possibly the software you're using runs an old version of python
11th Aug 2019, 4:31 AM
Lucas Otavio Nascimento De Araujo
Lucas Otavio Nascimento De Araujo - avatar