[Tutor] How sum() works in python

ramakrishna reddy rampappula at gmail.com
Tue Aug 1 02:06:18 EDT 2017


Hi All,

I know

> sum([1,2,3]) returns 6.

But sum with [] 'empty list' as second parameter returns as below.

> sum([[1,2,3], [3,4,5]], []) returns [1, 2, 3, 3, 4, 5]
Can any one please explain this logic ? I searched in google but could not
find the suitable answer.

Thanks in advance.


Thanks,
Ram.


More information about the Tutor mailing list