lambda & filter() - pycharms 2021.2.2 community edition


I try this code:

rge = range(21)
is_even = lambda x: x % 2 == 0
evens = list(filter(is_even, rge))

Why this code doesn't run in pychams and running without any issue on How I can solve this issue? Would you please help me. Thanks a lot. Lisa

Error-messag is:

Traceback (most recent call last):
File "c:\....\", line 165, in <module>
evens = list(filter(is_even, rge))
TypeError: 'list' object is not callable

Please sign in to leave a comment.