How to make for all below sorted array?

Pay no attention to this code:

import random


p = []
n = []
x = random.randint(2,7)
y = x + random.randint(2,5)
a = [[random.randint(-20, 20) for i in range(x)] for j in range(y)]
b = [[random.randint(-20, 20) for i in range(x)] for j in range(y)]

print('the Random matrix: ')
for i in a:
 for j in i:

 print('|', j, end=' ')

print('|')

b = zip(*a)
print('Transposed matrix: ')
for i in b:
 for j in i:

 print('|', j, end=' ')
n.append(i[::2])
print('|')

print(n)

z = 0
for m in n:
 m = sorted(n[z],key=int, reverse=False)
z+=1
print(m)

I'm interested in these lines:
z = 0
for m in n:
 m = sorted(n[z],key=int, reverse=False)
z+=1
print(m)

I do not understand why the loop iterates through the entire array
March 23rd 20 at 19:27
0 answer

Find more questions by tags Python