title: Python: String formatting to the right side
body: <p>Here is my source code:</p>
  
  <pre><code>def fibonacci_numbers():
    how_many_numbers = int(input("\nHow many Fibbonacci numbers you want print: "))
    i = 0
    res = [0, 1]
    while i &lt; how_many_numbers:
        res.append(sum(res[-2:]))
        print("{}. {}".format(i + 1, res[i]))
        i += 1
  
  
  fibonacci_numbers()
  </code></pre>
  
  <p>The output now is:</p>
  
  <pre><code>How many Fibbonacci numbers you want print: 30
  1. 0
  2. 1
  3. 1
  4. 2
  5. 3
  6. 5
  7. 8
  8. 13
  9. 21
  10. 34
  11. 55
  12. 89
  13. 144
  ...
  30. 514229
  </code></pre>
  
  <p>But I need something like that:</p>
  
  <pre><code>How many Fibbonacci numbers you want print: 30
  1.       0
  2.       1
  3.       1
  4.       2
  5.       3
  6.       5
  7.       8 
  8.      13
  9.      21
  10.     34
  11.     55
  12.     89
  13.    144
  ...
  30. 514229
  </code></pre>
  
  <p>and so on. It's depending for a numbers I choose. If i take 50 numbers so I need more spaces, but everything need to be placed to the right side.</p>
  
  <p>How I can achieve this?</p>
  
  <p>I tried with <code>{:&gt;width}</code> and with <code>.rjust</code> method, but I can't get it.</p>
  
  <p>Is there simple solution for that?</p>
  
  <p>Or maybe I need make another loop and print there?</p>
  
  <p><strong><em>Final Solution:</em></strong></p>
  
  <p>Thanks for answers. I pick up some of them and i made this:</p>
  
  <pre><code>def fibonacci_numbers():
  
      how_many_numbers = int(input("\nHow many Fibbonacci numbers you want print: "))
      i = 0
      res = [0, 1]
      while i &lt; how_many_numbers:
          res.append(sum(res[-2:]))
          i += 1
  
      size_of_i = len(str(i))
      i = 0
      for num in res[:-1]:
          size = len(str(res[-2]))
          print("{:&lt;{width_of_i}} {:&gt;{width}}".format(str(i)+":", num, width_of_i=size_of_i + 1, width=size))
          i += 1
  
  
  
  fibonacci_numbers()
  </code></pre>