Форум сайта python.su
0
Подскажите как исправить код чтобы все работало
N = int(input())
M = int(input())
mat = [[int(i) for i in input().split()] for _ in range(N)]
m = int(input())
t = int(input())
for i in range(N):
mat[i][m],mat[i][t] = mat[i][t],mat[i][m]
for row in mat:
print(*row)
Офлайн
857
Всё работает и так.
Добавил сообщения
>>> def f(): ... N = int(input('Enter the number of rows: ')) ... M = int(input('Enter the number of columns: ')) ... ... mat = [[int(i) for i in input('Enter a row: ').split()] for _ in range(N)] ... ... m = int(input('Enter the first column number: ')) ... t = int(input('Enter the second column number: ')) ... ... for i in range(N): ... mat[i][m],mat[i][t] = mat[i][t],mat[i][m] ... ... for row in mat: ... print(*row) ... >>> f() Enter the number of rows: 3 Enter the number of columns: 4 Enter a row: 1 2 3 4 Enter a row: 5 6 7 8 Enter a row: 4 3 2 1 Enter the first column number: 0 Enter the second column number: 3 4 2 3 1 8 6 7 5 1 3 2 4 >>>
Офлайн
0
py.user.nextУ меня в pycharme тоже все работает, а автотест на степике и pydroid ошибку выдает. Пришлось чутка исправить и все заработало))
Всё работает и так.Добавил сообщения
Офлайн
61
anotcherМы так драйвера на 98 винде ставили…
Офлайн