Python Lambda Function that always returns None
Lambda Function that returns None in Python
In Python, we can define a Lambda Function that always returns None.
The following lambda function always returns None, for any arguments.
lambda *args, **kwargs: None
Examples
1. Write a lambda function that returns None
In the following program, we define a lambda function, mylambda
, that always returns None.
Python Program
myLambda = lambda *args, **kwargs: None
print(myLambda())
Output
None
Try passing some arguments to the lambda function. Still it returns None.
Python Program
myLambda = lambda *args, **kwargs: None
print(myLambda(14, 36, 'apple'))
Output
None
Summary
In this tutorial of Python Lambda Functions, we learned how to write a lambda function that always returns None.