Tiny python code I dont understand

ast nomail at invalid.com
Tue Mar 8 11:32:22 EST 2016


"ast" <nomail at invalid.com> a écrit dans le message de news:56defc8e$0$3341$426a74cc at news.free.fr...
> Hello
>
>>>> lst = [(1,2,3), (4, 5,6)]
>>>> sum(lst, ())
> (1, 2, 3, 4, 5, 6)
>
> Any explanations ?
> thx

OK, sorry, I finally understand.
This is because adding tuple (or list or string ...) is a concatenation

() + (1,2,3) + (4, 5,6)
(1,2,3,4,5,6)




More information about the Python-list mailing list