title: While printing how to snip space from the end of the list
body: <p>Hi i need to remove a white space at the end of each line while printing to a file from a list.</p>
  
  <p>Here is my code</p>
  
  <pre><code>lst =[['Apple',330.0, 2.2 ,'Kg'],['banana',22,330.0, 2.2 ,'Kg']]
  g = open('Receipt.txt', 'w')
  l=0
  p=''
  for i in lst:
      for j in range(len(lst[l])):
          print(lst[l][j],end=' ',file=g)
      l += 1
  g.close()
  </code></pre>
  
  <p>need output in file like this:</p>
  
  <pre><code>Apple 330.0 2.2 Kg
  banana 22 330.0 2.2 Kg 
  </code></pre>
  
  <p>I have used this for loop to write all the indexes in single line with help of end = ' ' but unfortunately its creating a space at the end of each line. Which is a issue for me. </p>
  
  <p>How can we add a condition that if lst index reaches -1 which is last index 'kg' it shouldn't include space in that one.</p>
  
  <p>Simplest solution needed please</p>