Two possibile solutions: seq = [2, 3, 1, 9]
print sum( ([i]*n for i,n in enumerate(seq)), []) print [i for i, x in enumerate(seq) for _ in xrange(x)] The second one is probably quite faster. Bye, bearophile -- http://mail.python.org/mailman/listinfo/python-list