A and B but not C in list
Corey Richardson
kb1pkl at aim.com
Sun Jan 23 16:13:24 EST 2011
On 01/23/2011 04:05 PM, CM wrote:
> In Python, is there a recommended way to write conditionals of the
> form:
>> "if A and B but not C or D in my list, do something." ?
>> I may also have variations on this, like "if A but not B, C, or D".
>> Do I have to just write out all the if and elifs with all possible
> conditions, or is there a handier and more code-maintainable way to
> deal with this?
>> Thanks.
>>>>
if (A in list and B in list) and (C not in list or D not in list):
pass
I'm sure the gurus on this list can come up with something better.
More information about the Python-list
mailing list