So basically you'll need to fill up a matrix in a spiral pattern.
Here's a pseudo-code for it so you can write the actual Python code (it's an assignment, you should work on it and not just simply get a ready solution). Of course, there are many solutions, this is just one proposal.
The idea is to use a state machine to follow the spiral pattern: move right, then down, then left, then up and then it starts over until the whole matrix is filled.
var n = InputFromUser();
var array[n, n];
var horizontal_min = 0;
var horizontal_max = n - 1;
var vertical_min = 0;
var vertical_max = n - 1;
var totalNumbers = n * n;
var x = horizontal_min;
var y = vertical_min;
enum States { horizontal_plus, vertical_plus, horizontal_minus, vertical_minus }
var state = States.horizontal_plus;
for (i = 1; i <= totalNumbers; i++)
array[x, y] = i;
switch (state)
case horizontal_plus:
x++;
if (x == horizontal_max)
state = vertical_plus;
vertical_min++;
case vertical_plus:
y++;
if (y == vertical_max)
state = horizontal_minus;
horizontal_max--;
case horizontal_minus:
x--;
if (x == horizontal_min)
state = vertical_minus;
vertical_max--;
case vertical_minus:
y--;
if (y == vertical_min)
state = horizontal_plus;
horizontal_min++;
Good luck!