def to_int(bit_string, base=2):
    """
    Convert a sequence of bits into an integer.
    :param bit_string: Sequence of zeros and ones
    :param base: The base
    :return: An integer or 0 if no valid bit_string was provided
    """
    if bit_string:
        return int(bit_string, base)
    return 0