title: Python script to convert octal to string eg octal(755) to (rwxr-xr-x). Stuck at adding the dash seperator
body: <p>Below is the script printing the converted octal to string. I would appreciate suggestion on how to add the - separator to the string on each permission (r/w/x)</p>
  
  <pre class="lang-py prettyprint-override"><code>def octal_to_string(octal):
      result = ""
      value_letters = [(4,"r"),(2,"w"),(1,"x")]
      #Iterating over each digit in octal
      for digit in [int(n) for n in str(octal)]:
  
          #Checking for each of permission values
          for value, letter in value_letters:
              if digit &gt;= value:
                  result += letter
                  digit -= value
              else:
                  pass
      return result
  </code></pre>
  
  <p>I currently get:</p>
  
  <pre><code>In [7]: octal_to_string(755)
  Out[7]: 'rwxrxrx'
  
  In [8]: octal_to_string(644)
  Out[8]: 'rwrr'
  </code></pre>