matrix1 = [ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 7, 8, 9 ] ] matrix2 = [ [1, 2, 3, 4], [4,5,6,7], [7,8,9,10] ] matrix3 = [ [2,5,8],[4,0,-1] ] def spiralMatrix1(matrix): if not matrix: return [] start_row = 0 end_row = len(matrix) start_col = 0 end_col = len(matrix[0]) output = [] while start_row