Octal to Decimal conversion of number

Question:

I want to convert an octal number into a decimal one. Why am I getting 6 as an output instead of 83?

import math

def octalToDecimal(octalNumber):
    decimalNumber = 0
    i = 0
    while (math.floor(octalNumber) != 0):
        rem = math.floor(octalNumber) % 10
        octalNumber /= 10
        decimalNumber += rem * 8**i
        ++i
    print(decimalNumber)

octalToDecimal(123) 
Asked By: Jordan G

||

Answers:

write i+=1 instead of ++i,theres no such operator as ++ in python

Answered By: Ülke Eren Aktaş
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.