repeat items in a list
beliavsky at aol.com
beliavsky at aol.com
Sat Mar 26 18:12:37 EDT 2016
More information about the Python-list mailing list
Sat Mar 26 18:12:37 EDT 2016
- Previous message (by thread): help with program
- Next message (by thread): repeat items in a list
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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?
- Previous message (by thread): help with program
- Next message (by thread): repeat items in a list
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list