multiply utple or list

Karl Scalet news at yebu.de
Thu Feb 19 09:45:38 EST 2004


Jim Red wrote:
> what is the best way to multiply a tuple or list by a given value
> 
> exp.
> multiply (4, 5) by 2 => (8, 10)
> 
> cheers
> 
> jr

i.e.:

 >>> import operator
 >>> [ operator.mul(x,2) for x in (4,5)]

regards,
Karl




More information about the Python-list mailing list