Anthony Tolle <anthony.to...@gmail.com> writes: > def xor(*operands): > if operands: > operands = list(operands) > a = bool(operands.pop(0)) > while operands: > b = bool(operands.pop(0)) > if a: > if b: > a = False > elif b: > a = True > return a > return False
Among other things, that uses quadratic time! Why do you want to keep popping items from that list instead of iterating through it anyway? Anyway, I think you wrote something close to this: def xor(*operands): r = False for x in operands: r = (r != bool(x)) return r or in map-reduce style: from operator import ne def xor(*operands): return reduce(ne, map(bool, operands), False) -- http://mail.python.org/mailman/listinfo/python-list