July 2022 1 8 Report
Помогите, пожалуйста, понять, что нужно поменять в коде, чтобы не было след. ошибки:

Traceback (most recent call last):
File "main.py", line 7, in
a[p-1][i], a[q-1][i] = a[q-1][i], a[p-1][i]
IndexError: list index out of range

Сам код вот:
N,M = map(int,input().split())
a = [[int(j) for j in input().split()] for i in range(N)]
#n,m=[int(i) for i in input().split()]
p,q = map(int,input().split())
for i in range(N):
a[p-1][i], a[q-1][i] = a[q-1][i], a[p-1][i]
print(a[i])

Please enter comments
Please enter your name.
Please enter the correct email address.
You must agree before submitting.

Answers & Comments


Copyright © 2024 SCHOLAR.TIPS - All rights reserved.