Hi All,
I want to invoke a function with return statement using list comprehension or even lambda (if possible) for the better performance. Below is code snippet where I am trying to achieve that in list comprehension where if that function return Fail then break the flow and control move to next statement.
Similarly how to assign a value using list comprehension?
Regards,
Maiya
I want to invoke a function with return statement using list comprehension or even lambda (if possible) for the better performance. Below is code snippet where I am trying to achieve that in list comprehension where if that function return Fail then break the flow and control move to next statement.
def func(var): return True if var % 2 else False l = [2, 2, 3, 4] new_list = [out for var in l out = func(var) if out == False break] print(new_list)
Output:[True, True]
But then I could not able to achieve the desired result, I would really appreciate if any suggestion on this. Similarly how to assign a value using list comprehension?
Regards,
Maiya