Am a beginner on Python (self studying) and got introduced to Lambda (nameless) function but I am unable to deduce the below expression for Fibonacci series (got from Google) but no explanation available online (Google) as to how this is evaluated (step by step). Having a lot of brain power here, I thought somebody can help me with that. Can you help evaluate this step by step and explain ?
lambda n: reduce(lambda x, _: x+[x[-1]+x[-2]],range(n-2), [0, 1])
Thanks in advance.
(Thanks xnkr, for the suggestion on a reduce function explained and yes, am able to understand that and it was part of the self training I did but what I do not understand is how this works for lambda x, _ : x+[x[-1]+x[-2]],range(n-2), [0, 1]. It is not a question just about reduce but about the whole construct - there are two lambdas, one reduce and I do not know how the expression evaluates to. What does underscore stand for, how does it work, etc)
Can somebody take the 2 minutes that can explain the whole construct here ?