Question: Imagine you need to count number of `iterable` elements that satisfy some `criteria` - is there is a more good looking way to do this?
It's python3 of course. But 2 is fine too.
I can't find anything suitable in `collections` or `itertools` python modules or in built-ins.

Answer: 
```
sum(1 for i in A if condition(i))

```
> 
> List comprehensions provide a concise way to create lists. Common
>  applications are to make new lists where each element is the result of
>  some operations applied to each member of another sequence or
>  iterable, or to create a subsequence of those elements that satisfy a
>  certain condition.
> 
> 
> 

```
>>> squares = []
>>> for x in range(10):
...     squares.append(x**2)
...
>>> squares
[0, 1, 4, 9, 16, 25, 36, 49, 64, 81]

```

> 
> Note that this creates (or overwrites) a variable named x that still
>  exists after the loop completes. We can calculate the list of squares
>  without any side effects using:
> 
> 
> 

```
squares = list(map(lambda x: x**2, range(10)))

```

> 
> or, equivalently:
> 
> 
> 

```
squares = [x**2 for x in range(10)]

```

than just put you conditon in the the if statment like this

```
>>> [(x, y) for x in [1,2,3] for y in [3,1,4] if x != y]
[(1, 3), (1, 4), (2, 3), (2, 1), (2, 4), (3, 1), (3, 4)]

```

you got a list of elements which meet the condition, and you can use `len(lsit_)` to count the elements

[List Comprehension Document](https://docs.python.org/3/tutorial/datastructures.html#list-comprehensions)