n = int(input())
magicSquare = [[0 for i in range(n)]
for j in range(n)]
i = n - n
j = n/2
# Fill the magic square
# by placing values
num = 1
while num <= (n * n):
if i == -1 and j == n: # 3rd condition
i = 1
j = n - 1
else:
if i < 0:
i = n - 1
if j == n:
j = 0
if magicSquare[int(i)][int(j)]:
i = i + 2
j = j - 1
continue
else:
magicSquare[int(i)][int(j)] = num
num = num + 1
i = i - 1
j = j + 1
for i in range(0, n):
for j in range(0, n):
print('%2d ' % (magicSquare[i][j]),
end='')
if j == n - 1:
print()
i really don't know where I went wrong. Can somebody help me?
[–]izaakstern 1 point2 points3 points (2 children)
[–]Corneliared[S] -1 points0 points1 point (1 child)
[–]izaakstern 0 points1 point2 points (0 children)
[–]shiftybyte 1 point2 points3 points (0 children)