-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
  • 23,210
  • 7
  • 49
  • 68

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
  • 9,043
  • 4
  • 12
  • 31
Dan Constantinescu
  • 1,151
  • 1
  • 5
  • 10