[Tutor] List comprehension
Thu Apr 10 23:53:02 2003
Danny Yoo has already answered your question in January this year.
You can find Danny's answer at
In short, the way to do it is to use the reduce() function:
myList = [1,2,3,4,5,6]
sum = reduce(operator.add, myList)
All the best,
At 10:12 AM 11/04/03 +0700, Nova Sano S. Surbakti wrote:
>How can I simplify this lines:
> > sum = 0
> > myList = [1,2,3,4,5,6]
> > for each in myList:
> > sum += each
>Into shorter, more elegant line(s)?