Multiply a tuple by a constant

Larry Bates lbates at
Fri Feb 13 16:56:17 CET 2004

two ways:

newt=tuple(map(lambda x: x*0.5, t))

Note: apparently the map function is slated for deprication
(to be replaced by list comprehension)

List comprehension:

newt=tuple([x*0.5 for x in t])

-Larry Bates
"Jay Davis" <dj00302003 at> wrote in message
news:1d17eeb7.0402130220.7258a5bd at
> I often need to multiply a tuple by a
> constant and the methods I use now are
> not very pretty.  The idea is to get a
> new tuple that is some factor times the
> start tuple, like  'newtup = .5 * oldtup'.
> Is there a slick way to do this?

More information about the Python-list mailing list