how to append to a list twice?
Nick Craig-Wood
nick at craig-wood.com
Fri Apr 21 15:30:03 EDT 2006
Edward Elliott <nobody at 127.0.0.1> wrote:
> John Salerno wrote:
> > If I want to create a list of the form [100, 99, 99, 98, 98, 97, 97...]
> > (where each item is repeated twice after the first one), how might I do
> > that most efficiently?
>
> Why not just this:
>
> series = [x/2 for x in range(200, 1, -1)]
That should be
series = [x//2 for x in range(200, 1, -1)]
to be "from __future__ import division" safe
--
Nick Craig-Wood <nick at craig-wood.com> -- http://www.craig-wood.com/nick
More information about the Python-list
mailing list