title: Python Logic - Centering text using periods
body: <p>I'm taking <a href="http://cscircles.cemc.uwaterloo.ca/8-remix/" rel="nofollow">this intro to python course online</a></p>
  
  <p>The problem reads:</p>
  
  <blockquote>
    <p>For this program, the first line of input is an integer width. Then, there are some lines of text; the line "END" indicates the end of the text. For each line of text, you need to print out a centered version of it, by adding periods .. to the left and right, so that the total length of each line of text is width. (All input lines will have length at most width.) Centering means that the number of periods added to the left and added to the right should be equal if possible; if needed we allow one more period on the left than the right. For example, for input</p>
  </blockquote>
  
  <pre><code>13
  Text
  in
  the
  middle!
  END
  </code></pre>
  
  <p>the correct output would be</p>
  
  <pre><code>.....Text....
  ......in.....
  .....the.....
  ...middle!...
  </code></pre>
  
  <p>the Hint given is:</p>
  
  <blockquote>
    <p>For input line length of L, you should add (width-L)\\2 periods to the right side</p>
  </blockquote>
  
  <p>Here is my code so far:</p>
  
  <pre><code>width = int(input())
  s1 = input()
  
  periods_remain = width - len(s1)
  L = periods_remain
  periods_rtside = (width-L)//2
  periods_leftside = width - periods_rtside
  periods_rt_str = '.' * periods_rtside
  periods_left_str = '.' * periods_leftside
  line1 = periods_left_str + s1 + periods_rt_str
  </code></pre>
  
  <p>My line1 result looks like "...........Text.." Instead of .....Text....</p>
  
  <p><a href="http://cscircles.cemc.uwaterloo.ca/visualize/#code=width+%3D+int%28input%28%29%29%0As1+%3D+input%28%29%0A%0Aperiods_remain+%3D+width+-+len%28s1%29%0AL+%3D+periods_remain%0Aperiods_rtside+%3D+%28width-L%29//2%0Aperiods_leftside+%3D+width+-+periods_rtside%0Aperiods_rt_str+%3D+%27.%27+%2a+periods_rtside%0Aperiods_left_str+%3D+%27.%27+%2a+periods_leftside%0Aline1+%3D+periods_left_str+%2B+s1+%2B+periods_rt_str&amp;mode=display&amp;raw_input=13%0AText&amp;curInstr=0" rel="nofollow">It can be run here</a></p>
  
  <p>My problem seems to be the L. I'm not sure how to define L. Thanks!</p>