Summing Booleans For Fun And Profit

I came up with a IMHO nice piece of code while working with and getting to know Python.

This feels clean and obvious. It might not be very efficient though. :/

Doing it this way can be more efficient, since it can leverage generators and doesn’t need to go through the list again with any . But using  sum  over booleans feels hackish and non-obvious … 🙁

Leave a Reply

Your email address will not be published. Required fields are marked *