Is there an elegant way in python to make a list of duplicate things?
For example, I want to make a list of 7 lefts, like so:
x = ['left', 'left', 'left', 'left', 'left', 'left', 'left']
other than doing something like:
x = []
for y in xrange(7):
x.append('left')
is there a way to efficiently make a list of 7 lefts? I had hoped for something like:
x = ['left' * 7]
, but of course that gives me ['leftleftleftleftleftleftleft']
.
Thanks a lot, Alex