3 ms·
It's useful because it allows you to add together booleans to get a count of how many are true. You can check if two out of three are true with (bool1 + bool2
by bobbyi 16y ago
It's useful because it allows you to add together booleans to get a count of how many are true.
You can check if two out of three are true with
(bool1 + bool2 + bool3) >= 2
You can do
count_negatives = sum(number < 0 for number in numbers)