Conditions | 3 |
Total Lines | 17 |
Code Lines | 6 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | def count_truthy(items): |
||
2 | """ |
||
3 | Count non None values viz, but includes 0 |
||
4 | ---- |
||
5 | examples: |
||
6 | |||
7 | 1) count_truthy([1, 2, None, 'a']) -> 3 |
||
8 | 2) count_truthy([1, 2, 0, 'a']) -> 4 |
||
9 | ---- |
||
10 | :param items: list |
||
11 | :return: int |
||
12 | """ |
||
13 | counter = 0 |
||
14 | for item in items: |
||
15 | if item is not None: |
||
16 | counter += 1 |
||
17 | return counter |
||
18 | |||
33 |