I’m new to Python and I’m currently reading “Learn Python Programming, 3rd edition (Packt)”. I’m having issues trying to understand the following code:
list(map(lambda *a: a, range(3)))
1.) What’s the purpose of the lambda function? Is it unpacking the collection being passed as an argument into individual elements and then transforming it into the original collection?
2.) The output of this call is [(0,), (1,), (2,)]. Please help me understand how a tuple is generated as part of the list elements. I do not see any explicit call to create tuples in this statement and from what I have read the range function returns an immutable sequence of numbers.