a and b or c
is equivalent (almost since your case proves that it is not) so that
b if a else c
So:
a = [1,5,2,4] def func1(li,func2): for x,el in enumerate(li): li[x] = func2(el) func1(a,lambda x: 0 if x>3 else x) print a
Note:
By the way, have you noticed that you are changing the value of an object external to the function in the function?
u = 102 def f(x): x = 90 print "u==",u
result
u== 102
In your code, a changes because it is a mutable object
In general, a function has a return. You do not, because you are changing a mutable object.
source share