coding180 icon
Coding180

What is the main difference between lambda and def?

Home > Interviews > Python


robort - 2022-08-30 09:49:53

Lambda is a single-expression function, whereas def can hold multiple expressions.
def creates a function and names it so that it can be called later. Lambda creates and returns a function object.
A return statement is permissible in def. Return statements are not permitted in lambdas.
Lambdas are compatible with lists and dictionaries.


user

Robort Gabriel

Lagos, Nigeria

Freelance Web Developer, Native Android Developer, and Coding Tutor.

Skills
  • UI / UX
  • JavaScript
  • Python
  • PHP
  • Kotlin
  • Java
  • Bootrap
  • Android
  • Laravel