lambda function accessing outside variable [duplicate]
You can “capture” the i when creating the lambda lambda x, i=i: x%i==0 This will set the i in the lambda’s context equal to whatever i was when it was created. you could also say lambda x, n=i: x%n==0 if you wanted. It’s not exactly capture, but it gets you what you need. It’s an … Read more