"[EMAIL PROTECTED]" <[EMAIL PROTECTED]> writes: > > FWIW, the original loop looked perfectly fine and readable and I'd > > suggest going with that over these hacked-up listcomp solutions. Don't > > use a listcomp just for the sake of using a listcomp. > > Thanks for that, Carl. I think that using the loop is probably what > I'll end up doing. I had no idea that the listcomp thing would be quite > a complicated as it is appearing. I had it in my mind that I was > missing some obvious thing which would create a simple solution :)
I think even if you code a loop, it's still cleaner to use enumerate: seq = [2, 3, 1, 9] tmp = [] for i,a in enumerate(seq): tmp.extend([i]*a) -- http://mail.python.org/mailman/listinfo/python-list