News for hackers. Stuff that matters.
Re:Introduction to Object Oriented Programming in Python by vram22 on Friday October 26, 2018 @07:51AM (#18308388)
Yes, lambas don't allow statements in them, only an expression.

In [8]: f = lambda x: x * 2

In [9]: f(2)

Out[9]: 4

In [10]: g = lambda x: if x % 2 == 0: x * 2 else x * 3

  File "<ipython-input-10-f7248669b8fd>", line 1

    g = lambda x: if x % 2 == 0: x * 2 else x * 3
                   ^
SyntaxError: invalid syntax

There are no comments on this comment yet.