This is my code so far. It takes numbers as STRINGS and if needed splits them down. Then converts them from OCTAL to decimal. However, in the cases where multiple numbers come as a single string; after conversion, I need to reassemble them back into a single string again. The same format in which they arrived.
dataset = "120 156 206" #Just a testing sample
delimiter = " "
if delimiter in dataset:
text = dataset.strip('"')
text = text.split()
for i in text:
c = int(i, base=8)
var1 = "".join(str(c))
print(var1)
else:
c = int(dataset, base=8)
print(c)
The expected output should be: "80 110 134"
I've tried:
d = " ".join(str(c))
OUTPUT:
8 0
1 1 0
1 3 4
d += " ".join(str(c))
OUTPUT:
1 3 48 0
1 3 48 01 1 0
1 3 48 01 1 01 3 4
Also all kinds of other stuff that seems to just break everything, Type Errors etc...
Without the .join this is the closest I have got so far:
80
110
134
if delimiter in dataset:.split()will always return a list and if there was no delimiter, a single element will be there. Justsplitand loop...