0
I can't understand these code
code1 : a = [1] func = (lambda x: x.append("a")) and (lambda x: x.append("b")) func(a) print(a) out put is [1,"b"] code2: a = [1] func = (lambda x: x.append("a")) or (lambda x: x.append("b")) func(a) print(a) out put is [1,"a"] I don't understand. why the out put of code 1 is not [1,"a","b"] anyone can tell me how the code run? Thanks.
1 ответ
+ 4
Because and operator works in this way, when the first operand is true, it returns the second operand.