How to count non-null elements in an iterable?

前端 未结 0 1643
借酒劲吻你
借酒劲吻你 2021-02-13 00:58

I\'m looking for a better/more Pythonic solution for the following snippet

count = sum(1 for e in iterable if e)
相关标签:
回答
  • 消灭零回复
提交回复
热议问题