[Solved] Create a list of all the lists whose entries are in a range in Python [closed]


Are you looking for the product of [5, 6, 7] with itself, 57 times?

itertools.product() does that for you:

from itertools import product

for combination in product([5, 6, 7], repeat=57):
    print combination

This will take a while to print all output, however. It’ll eventually print all 3 ** 57 == 1570042899082081611640534563 possible combinations.

Don’t try and create a single list with all possible combinations, however. On a 64-bit machine one of these lists takes 528 bytes, so all lists together take roughly 685719 zetabytes (1 zetabyte is 1024 ** 8 bytes) of memory. Technology isn’t that far along yet.

2

solved Create a list of all the lists whose entries are in a range in Python [closed]