title: How to format a string using variables instead of numbers within curly braces?
body: <p>I'm using Python 3.7 and I have stored a value inside a variable. This variable holds the value of padding which I want to use within curly braces for string formatting. The code explains what I am trying to do.</p>
  
  <pre><code>def print_formatted(number):
      for i in range(1, number + 1):
          binum = bin(i).replace('0b', '')
          ocnum = oct(i).replace('0o', '')
          hexnum = hex(i).replace('0x', '')
  
          length = len(bin(number).replace('0b', ''))
          print('{0:&gt;length} {1:&gt;length} {2:&gt;length} {3:&gt;length}'.format(i, ocnum, hexnum, binum)) # Error here
  </code></pre>
  
  <p>This is the code that I have been trying to run. What I am trying to do is to right align the numbers by padding it by the value of the length of the last binary number.</p>
  
  <blockquote>
    <p>ValueError: Invalid format specifier</p>
  </blockquote>
  
  <p>This is the error I get. What am I doing wrong?</p>