LearnFrenzy
Sign in Take a free test

Lambda Functions · Find the Error · Question 3

Error: calling a lambda with too few arguments Answer, explanation & discussion

  • Find the error
  • Easy
  • 0 comments
  • Answer explained
  • Moderated community
Question 3 Back to Exercise

The program below stops with an error. Which statement correctly describes the problem?

main.py
area = lambda length, width: length * width
print(area(5))
  • A It prints 5
  • B It prints 25
  • C SyntaxError
  • D TypeError: the lambda needs two arguments but got one; pass width too or give it a default Correct
Correct Answer: Option D

Lambdas follow the same argument rules as def functions.

Discussion & Comments 0

Share your method, a shortcut, or ask about a step you didn't follow.

No comments yet. Be the first to share your solution!

Post your comment

Comments appear after a quick review by our team.

Search LearnFrenzy

Esc

Quick links