On 17/10/2026 18:08, John Bokma wrote:
> Examples: > > Explain as a professional Python programmer why 1+True yields 2 and is valid > Thought for 3s > > In Python,  bool  is a subclass of  int . The two Boolean values behave numerically as  False == 0  and  True == 1 , so adding  True  to  1  is equivalent to  1 + 1 : > > 1 + True       # 2 > type(1 + True) # int > > It’s valid because Python’s numeric operations accept Boolean values as integers. In application code, though, it’s usually clearer to convert or count explicitly if you intend to use a Boolean as a number.
With Booleans the + operator ought to be an OR function so TRUE + TRUE = TRUE
-- “The urge to save humanity is almost always only a false face for the urge to rule it.” – H. L. Mencken