Syntax

Python Lambda Function Syntax

In Python, lambda function: creates a small anonymous function — square = lambda x: x * x

Quick Answer

Syntax
square = lambda x: x * x
PythonSyntax

Lambda Function

Code example
square = lambda x: x * x

Creates a small anonymous function.

Learn More

How to lambda function in Python

  1. Open your Python file or editor.
  2. Copy the example, then replace its sample names and values for your code.

Python Lambda Function Syntax

Use square = lambda x: x * x.

Related Syntax References

Frequently asked questions

What is the Python syntax for lambda function?

Use this pattern: square = lambda x: x * x

Can I copy this Python code example?

Yes. Use Copy code and adapt the example to your program.

Is this Python syntax different on Mac or Windows?

No. The language syntax is the same across operating systems.

Official source · How we verify