1 import random 2 3 M = 4 4 5 matrix = [ [ random.randint(0, 9) for x in range(M) ] for y in range(M) ] 6 7 print(matrix)