Re: how to duplicate array entries

2010-01-11 Thread Munir
> I have an array  x=[1,2,3]
>
> Is there an operator which I can use to get the result
> [1,1,1,2,2,2,3,3,3] ?
>
> I tried x*3, which resulted in [1,2,3,1,2,3,1,2,3]

Have you tried:

y = x*3
y.sort()

Munir
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how to duplicate array entries

2010-01-17 Thread Munir
On Jan 11, 12:56 am, Munir  wrote:
> > I have an array  x=[1,2,3]
>
> > Is there an operator which I can use to get the result
> > [1,1,1,2,2,2,3,3,3] ?
>
> > I tried x*3, which resulted in [1,2,3,1,2,3,1,2,3]
>
> Have you tried:
>
> y = x*3
> y.sort()
>
> Munir

A single line version of this:

sorted(x*3)

Munir
-- 
http://mail.python.org/mailman/listinfo/python-list