Practice mode Python

Which limitation applies to a lambda expression in Python?

Correct answer D. Its body must be a single expression

Explanation

A lambda creates a small anonymous function whose body is restricted to one expression, whose value is returned automatically. It cannot contain statements such as assignments with =, return or loops. It can take any number of arguments, accept defaults and be assigned to a name, although PEP 8 prefers def for named functions.

Report a problem

Answer checked How we write and check questions

Tip: press A, B, C or D to answer, and N for the next question.

Advertisement

Have a question about this answer?

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

Links and website addresses are not allowed in comments.