"John Salerno" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> I'm sure it's not necessary. Basically W, X, Y and Z are propositions
> that are either true or false, and the puzzle lists a few statements
> such as "Exactly one of X, Y and Z is true", and I'm trying to work out
> a little algorithm that might test for this kind of stuff.

X+Y+Z == 1 # or bool(X)... if not booleam

> Another thing I'm trying to do is write a function that tests to see if
> a list contains exactly one true item, and the rest are false (obviously
> this would have to be a list of boolean values, I guess). I'm sure this
> isn't a handy utility, but I enjoy figuring out how to implement it.

Use sum().  Being able to count true values by adding is a reason bool is a 
subclass of int.

Terry Jan Reedy



-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to