title: to change multiple space in text file into a $ sign in python
body: <p>I try to change the multiple spaces in text file into a $ sign .</p>
  <p>I tried this it works and make all spaces 1 space but I need to read all the text file if find space more than 2 it convert it into $ sign</p>
  <pre><code>fin = open(&quot;data.txt&quot;, &quot;rt&quot;)
  fout = open(&quot;out.txt&quot;, &quot;wt&quot;)
  
  for line in fin:
      fout.write(' '.join(line.split()))
      
  fin.close()
  fout.close()
  </code></pre>