Ask a Question

Python# Given m and n, swap the mth and nth rows of the 2-D NumPy array given below.
m=int(input())
n=int(input())
a[[m,n]] = a[[n,m]] <---- # swapping
print(a)
# i can't understand line 4 since it has bracket [ ] inside [ ] .
# i know how to do this one a[m,n] but don't know about a[[m,n]] .
# can anyone explain briefly

Given m and n, swap the mth and nth rows of the 2-D NumPy array given below.
m=int(input())
n=int(input())
a[[m,n]] = a[[n,m]] <---- # swapping
print(a)
# i can't understand line 4 since it has bracket [ ] inside [ ] .
# i know how to do this one a[m,n] but don't know about a[[m,n]] .
# can anyone explain briefly

Fuel your ambition, discover your passion and achieve your professional goals with LetsUpgrade.

Sign Up Now