Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #105540 > unrolled thread

Re: 0 equals False, was Re: (unknown)

Started byINADA Naoki <songofacandy@gmail.com>
First post2016-03-23 11:12 +0000
Last post2016-03-23 11:12 +0000
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: 0 equals False, was Re: (unknown) INADA Naoki <songofacandy@gmail.com> - 2016-03-23 11:12 +0000

#105540 — Re: 0 equals False, was Re: (unknown)

FromINADA Naoki <songofacandy@gmail.com>
Date2016-03-23 11:12 +0000
SubjectRe: 0 equals False, was Re: (unknown)
Message-ID<mailman.48.1458731602.2244.python-list@python.org>
Tips: Since True == 1, sum() can count Trues.

>>> def count_even(seq):
...     return sum(i%2 == 0 for i in seq)

>>> count_even(range(100))
50

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web