simultaneous assignment
Terry Reedy
tjreedy at udel.edu
Tue May 2 15:57:29 EDT 2006
"John Salerno" <johnjsal at NOSPAMgmail.com> wrote in message
news:tsM5g.2033$No6.43913 at news.tufts.edu...
> 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
More information about the Python-list
mailing list