+ 5
I do not know how to rotate the matrix. This is the only solution that I can come up with:(((
print("rotate matrix") lis=[(1,2,3), (4,5,6), (7,8,9)] print(lis[2][0],lis[1][0],lis[0][0]) print(lis[2][1],lis[1][1],lis[0][1]) print(lis[2][2],lis[1][2],lis[0][2])
6 Respostas
+ 5
You essentially did the first step already. Now you should figure what the pattern is.
+ 4
From:https://stackoverflow.com/questions/8421337/rotating-a-two-dimensional-array-in-JUMP_LINK__&&__python__&&__JUMP_LINK
lis=[(1,2,3),(4,5,6),(7,8,9)]
print(lis)
rotated = list(zip(*lis[::-1]))
print(rotated)
+ 4
Khai123, zip function works buddy....
https://code.sololearn.com/cOVT4TReW0CS/?ref=app
+ 1
thanks Bro
+ 1
I used to use zip but it did not work