-2

I am trying to understand lambda Python code. How to translate this in normal Python?

self.myarray = [j for j in line if j.type not in (obj.key1, obj.key2)]
wjandrea
  • 28,235
  • 9
  • 60
  • 81

1 Answers1

1

That syntax represents a list comprehension and it does the same thing as below code:

self.myarray = []
for j in line:
    if j.type not in (obj.key1, obj.key2):
        self.myarray.append(j)
Chris
  • 26,361
  • 5
  • 21
  • 42
Dan Constantinescu
  • 1,426
  • 1
  • 7
  • 11