[Tutor] initialising all elements of a matrix

bob gailer bgailer at gmail.com
Tue Feb 28 18:26:52 CET 2012


On 2/28/2012 11:40 AM, Peter Otten wrote:

def product(factors, product=1):
     for factor in factors:
         product *= factor
     return product

can be "simplified"

def product(factors):
   import operator
   return reduce(operator.mul, factors)

-- 
Bob Gailer
919-636-4239
Chapel Hill NC



More information about the Tutor mailing list