Read Octal Numbers

In the octal number system, each position represents a power of 8, and the allowed digits are 0 through 7. The function parse_octal receives a string digits written in octal form and converts it to a decimal number. If an invalid digit appears, raise ValueError.

Примеры

Ввод
"1"
Вывод
1
Ввод
"10"
Вывод
8
Ввод
"17"
Вывод
15

Нужно реализовать

def parse_octal(digits: str) -> int:

Теги

mathstrings
PostgreSQLv16

Šeit parādīsies koda izpildes rezultāts

Visible tests
1
Input
"1"
Expected1
2
Input
"10"
Expected8
3
Input
"17"
Expected15
4
Input
"130"
Expected88
5
Input
"2047"
Expected1063
6
Input
""
Expected0
Focus radio
Paused · SomaFM · Fluid