0
Ich bin ein Neuling für Python, und stieß auf ein Problem mit Matrixrotation. Im Anschluss an meinem CodeMatrix Rotation Unerwartetes Ergebnis
def rotateMatrix(matrix):
if matrix == []:
return []
row, col = len(matrix), len(matrix[0])
res = [[0]*row]*col
for i in range(row):
for j in range(col):
res[col-1-j][i] = matrix[i][j]
return res
mat = [[1,2,3,4],[5,6,7,8],[9,10,11,12]]
print rotateMatrix(mat)
Das Drucker ist [4,8,12] für alle 4 Reihen !!! Ich weiß einfach nicht, wo das Problem ist
@beat mich durch eine min ;-) – Bobby
Vielen Dank! Ich habe gerade irgendwo eine Nullmatrix mit [[0] * r] * c erzeugt und das Problem hier nicht erkannt –