Question 9
Back to Exercise
Which lambda is valid?
- A lambda n: if n % 2 == 0: "even"
- B lambda n: "even" if n % 2 == 0
- C lambda n: "even" if n % 2 == 0 else "odd" Correct
- D lambda n: return "even"
Correct Answer: Option C
A conditional expression needs both if and else parts; an if statement is not allowed.
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!