[Tutor] How sum() works in python

Abdur-Rahmaan Janhangeer arj.python at gmail.com
Tue Aug 1 04:27:36 EDT 2017


i guess it adds / sort of concatenates the list

On Tue, Aug 1, 2017 at 10:06 AM, ramakrishna reddy <rampappula at gmail.com>
wrote:

> 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.
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>


More information about the Tutor mailing list