What is a lambda function?

Python control flow and functions · Freshers and experienced

Model answer

A small anonymous function written in one expression: lambda x: x * 2. It is handy as a short argument, for example sorted(users, key=lambda u: u["age"]). For anything complex, write a normal named function.

Learn this topic

Functions in Python: def, Arguments and return in the course Python for Beginners: Learn to Code with Real Projects.

Sign in to add your own answer.

More questions