Am stuck with some code. Am trying to write a function to translate octal to decimal accepting a string containing octal data (either a single number or a sequence of numbers separated by spaces) using loops and logic to return a string that contains one or more decimal numbers separated by spaces.
So far I have:
def decode(code):
decimal = 0
code = code.split(" ")
l = len(code)
for i in range (l):
octal = len(i)
for x in range (octal):
digit_position = x - 1
decimal += pow(8, digit_position) * int(x)
result = str(decimal)
Produces an error. Any ideas?