Use of Lambda function in Python

This post is about Lambda which remain one of the most confusing topic for beginners. After reading couple of articles, here I’m sharing gist of them.
Lambda is used to create function like def() but it returns the function instead of assigning name to it. This is the reason it is also called anonymous function.

Lambda function enable to add functionality where we don’t need to call function more than once.
For more understanding, have a look at the difference of lambda from function.

how to use lambda


Taking another example of for loop with and without Lambda,

Without Lambda


With Lambda, we can achieve the same result in one line.


Few more examples here:

One Response to “Use of Lambda function in Python”

Leave a Reply

Your email address will not be published. Required fields are marked *