def count(sequence, condition=None):
    """
    Returns number of item in a sequence satisfying given condition.
    
    Args:
        sequence: iterable
            Sequence of items to go through.
        
        condition: callable or None
            Condition to test.
    
    Returns:
        int
            Number of valid items.
    """
    
    if condition is None:
        return sum(1 for _ in sequence)
    
    return sum(1 for d in sequence if condition(d))