Spiral order
Write spiral(matrix) that returns the elements of a 2-D in clockwise spiral order, starting from the top-left corner.
Examples
spiral([[1, 2, 3], [4, 5, 6], [7, 8, 9]]) → [1, 2, 3, 6, 9, 8, 7, 4, 5]
Exercise
4 checksSpiral order
def spiral(matrix):
...
print(spiral([[1, 2, 3], [4, 5, 6], [7, 8, 9]]))
Press Run to try your code, then Check answer to grade it.