import random as rand # and when using it, type rand instead of random rows, cols = (10, 10) arr = [[rand.randrange(10) for i in range(cols)] for j in range(rows)] print(arr)