title: How to use Python to convert an octal to a decimal
body: <p>I had this little homework assignment and I needed to convert decimal to octal and then octal to decimal. I did the first part and could not figure out the second to save my life. The first part went like this:</p>
  <pre><code>decimal = int(input(&quot;Enter a decimal integer greater than 0: &quot;))
  
  print(&quot;Quotient Remainder Octal&quot;)
  bstring = &quot; &quot;
  while decimal &gt; 0:
      remainder = decimal % 8
      decimal = decimal // 8
      bstring = str(remainder) + bstring
      print (&quot;%5d%8d%12s&quot; % (decimal, remainder, bstring))
  print(&quot;The octal representation is&quot;, bstring)
  </code></pre>
  <p>I read how to convert it here: <a href="http://www.robotroom.com/NumberSystems4.html" rel="nofollow noreferrer">Octal to Decimal</a>, but I have no clue how to turn it into code.</p>