def bit_range(start, end, value):
    """
    Returns the bits between the `start` and `end` indices in the byte `value`.
    """
    int_value = int.from_bytes(bytearray(value), 'little')
    binary = bin(int_value)
    # Remove first two characters
    binary = binary[2:]
    # Extract bits
    bits = ''.join(reversed(''.join(reversed(binary))[start:end + 1]))  # Use "reversed()" instead of the less verbose [::-1] to be compatible with micropython
    # Convert to int
    return int(bits, 2)