I can create a list that has repeated elements of another list as follows:

xx = ["a","b"]
nrep = 3
print xx
yy = []
for aa in xx:
    for i in range(nrep):
        yy.append(aa)
print yy

output:
['a', 'b']
['a', 'a', 'a', 'b', 'b', 'b']

Is there a one-liner to create a list with repeated elements?
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to