lambda & filter() - pycharms 2021.2.2 community edition

Hello

I try this code:

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

Why this code doesn't run in pychams and running without any issue on https://www.online-python.com/? 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:\....\001_Zahlen.py", line 165, in <module>
evens = list(filter(is_even, rge))
TypeError: 'list' object is not callable

Please sign in to leave a comment.