I have seen many posts regarding how to flatten a list in Python. But I was never able to understand how this is working: reduce(lambda x,y:x+y,*myList)
Could someone please explain, how this is working:
>>> myList = [[[1,2,3],[4,5],[6,7,8,9]]]
>>> reduce(lambda x,y:x+y,*myList)
[1, 2, 3, 4, 5, 6, 7, 8, 9]
>>>
Linked already posted :
How to print list of list into one single list in python without using any for or while loop?
Flattening a shallow list in Python
Flatten (an irregular) list of lists
If anybody thinks this is duplicate to other post, I'll remove it once I understood how it works.
Thanks.