| 1 | 1 | def parse_octal(digits: str) -> int: |
| 2 | pass | |
| 2 | # Edge Case: Empty string input | |
| 3 | if not digits: | |
| 4 | return 0 | |
| 5 | ||
| 6 | result = 0 | |
| 7 | ||
| 8 | # Process each digit from left to right | |
| 9 | for digit in digits: | |
| 10 | # Edge Case: Invalid characters in octal string | |
| 11 | if not digit.isdigit() or int(digit) > 7: | |
| 12 | raise ValueError("Invalid octal digit: " + digit) | |
| 13 | ||
| 14 | # Convert the digit to integer and multiply by the appropriate power of 8 | |
| 15 | result = result * 8 + int(digit) | |
| 16 | ||
| 17 | return result | |
| 18 | # Handled Edge Cases: empty string input, invalid characters in octal string |