I want to create a series of lists, all of varying lengths. Each list will contain the same element e, repeated n times (where n = len
e
n
Itertools has a function just for that:
import itertools it = itertools.repeat(e,n)
Of course itertools gives you a iterator instead of a list. [e] * n gives you a list, but, depending on what you will do with those sequences, the itertools variant can be much more efficient.
itertools
[e] * n