xor operator
MRAB
python at mrabarnett.plus.com
Mon Nov 13 16:25:42 EST 2023
On 2023-11-13 21:03, Barry via Python-list wrote:
>
>
>> On 13 Nov 2023, at 17:48, Dom Grigonis <dom.grigonis at gmail.com> wrote:
>>
>> Short circuiting happens, when:
>> xor([True, True, False, False], n=1)
>> At index 1 it is clear that the answer is false.
>
> Can you share an example with 4 values that is true?
> And explain why it is xor.
>
I think what the OP wants is something that stops after finding n true
items.
It's a more general form of what 'any' and 'all' do - 'any' stops when
it finds 1 true item and 'all' stops when it finds 1 false item.
In general, you might want to stop when you find n true items or n false
items, or whatever.
More information about the Python-list
mailing list