I have recently discovered an interesting feature in python
If you type:
y=[[1,2],[3,4]]
sum(y,[])
Output is: [1, 2, 3, 4]
Does anyone know why the sum of a series of lists with an empty list gives a flattened version of y (i.e: all of the sub-lists of y as a single list)?
I would have expected the output to be a concatenation:
[1,2],[3,4],[]
Thanks