bama charan chhandogi https github combamacharanchhandogi description convert a octal number to binary references for better understanding https en wikipedia orgwikibinarynumber https en wikipedia orgwikioctal convert an octal number to binary octaltobinary17 001111 octaltobinary7 111 octaltobinaryav traceback most recent call last valueerror nonoctal value was passed to the function octaltobinary traceback most recent call last valueerror nonoctal value was passed to the function octaltobinary traceback most recent call last valueerror empty string was passed to the function convert an octal number to binary octal_to_binary 17 001111 octal_to_binary 7 111 octal_to_binary av traceback most recent call last valueerror non octal value was passed to the function octal_to_binary traceback most recent call last valueerror non octal value was passed to the function octal_to_binary traceback most recent call last valueerror empty string was passed to the function
def octal_to_binary(octal_number: str) -> str:
    
    if not octal_number:
        raise ValueError("Empty string was passed to the function")

    binary_number = ""
    octal_digits = "01234567"
    for digit in octal_number:
        if digit not in octal_digits:
            raise ValueError("Non-octal value was passed to the function")

        binary_digit = ""
        value = int(digit)
        for _ in range(3):
            binary_digit = str(value % 2) + binary_digit
            value //= 2
        binary_number += binary_digit

    return binary_number


if __name__ == "__main__":
    import doctest

    doctest.testmod()