multiply each element of a list by a number

Robert.T.Lynch at seagate.com Robert.T.Lynch at seagate.com
Sat Dec 27 01:05:09 CET 2008


What does *not* work is 
        3 * [0,1,2]
As you know, this gives
        [0,1,2,0,1,2,0,1,2]
What I am hoping for is
        [0,3,6]
I see that I can use 
        numpy.multiply(3,range(3))
but this seems overkill to me.  Can you tell I am coming to Python from 
Matlab?

Thanks -- Rob
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20081226/81e30b8b/attachment.html>


More information about the Python-list mailing list