# coding: utf-8
# Python 3.5.2
w, h = [int(input(x)) for x in ("Ширина: ", "Высота: ")]
matrix = [[0 for _ in range(h)] for _ in range(w)]
num = 1;
for col in range(w):
if (col + 1) % 2 == 1:
for a in range(h):
matrix[col][a] = num
num += 1
else:
for a in range(h - 1, -1, -1):
matrix[col][a] = num
num += 1
for col in range(h):
for row in range(w):
print(matrix[row][col], end=' ')
print()
---
Пример:
Ширина: 7
Высота: 5
1 10 11 20 21 30 31
2 9 12 19 22 29 32
3 8 13 18 23 28 33
4 7 14 17 24 27 34
5 6 15 16 25 26 35