Python Lambda Function that 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())
Run Code Copy

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'))
Run Code Copy

Output

None

Summary

In this tutorial of Python Lambda Functions, we learned how to write a lambda function that always returns None.

Related Tutorials

Code copied to clipboard successfully 👍