Walk square matrix in L/Z/O shape. L: down left col then right bottom. Z: top row, diagonal, bottom. O: clockwise border.
Implement this function:
def walk_matrix(M, shape) -> list:
Write the function only — the arguments are read for you and the return value is printed automatically.
Arguments arrive as one Python literal per line, in this order: M, shape.
Input
[[1, 2, 3], [4, 5, 6], [7, 8, 9]]
'L'
Output
[1, 4, 7, 8, 9]