title: Having trouble adding a space after a period in a python string
body: <p>I have to write a code to do 2 things:</p>
  
  <ol>
  <li><p>Compress more than one occurrence of the space character into one.</p></li>
  <li><p>Add a space after a period, if there isn't one.</p></li>
  </ol>
  
  <p>For example: </p>
  
  <pre><code>input&gt; This   is weird.Indeed
  output&gt;This is weird. Indeed.
  </code></pre>
  
  <p>This is the code I wrote:</p>
  
  <pre><code>def correction(string):
      list=[]
      for i in string:
          if i!=" ":
              list.append(i)
          elif i==" ":
              k=i+1
              if k==" ":
                 k=""
              list.append(i)
  
      s=' '.join(list)
      return s
  
  strn=input("Enter the string: ").split()
  print (correction(strn))
  </code></pre>
  
  <p>This code takes any input by the user and removes all the extra spaces,but it's not adding the space after the period(I know why not,because of the split function it's taking the period and the next word with it as one word, I just can't figure how to fix it)</p>
  
  <p>This is a code I found online:</p>
  
  <pre><code>import re
  def correction2(string):
    corstr = re.sub('\ +',' ',string)
    final = re.sub('\.','. ',corstr)
    return final
  
  strn= ("This   is as   .Indeed")
  print (correction2(strn))
  </code></pre>
  
  <p>The problem with this code is I can't take any input from the user. It is predefined in the program.
  So can anyone suggest how to improve any of the two codes to do both the functions on ANY input by the user?</p>