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
Melde dich an, um den Einreichungsverlauf zu sehen
AnmeldenMelde dich an, um den KI-Mentor zu nutzen
AnmeldenVisible tests
1
Input
"1"Expected
12
Input
"10"Expected
83
Input
"17"Expected
154
Input
"130"Expected
885
Input
"2047"Expected
10636
Input
""Expected
0Focus radio
Paused · SomaFM · Fluid