spiral_grid(n) that returns an n x n 2D list filled with the numbers 1 to n*n arranged in a clockwise spiral starting from the top-left corner, built using loops that walk the four boundary directions (right, down, left, up) and shrink the boundary each pass.spiral_grid(3)
[[1, 2, 3], [8, 9, 4], [7, 6, 5]]
Numbers spiral clockwise inward from the top-left.
Track four boundaries: top, bottom, left, right, and shrink each after traversing it.
Walk right across the top row, down the right column, left across the bottom row, and up the left column, in a loop that repeats until all cells are filled.