title: Formatting/Displaying list in python
body: <p>I'm new in python, I have a running code that extracts data from a web service and put it in a list and write it on a text file. When I run this code and open the text file, the data is continuous. I need something like in every line in text file, it will display 5 elements and will go to next line and write the next 5 elements and so on. Hope you can help me out on this or suggestion on other way to do this. Here's the code.</p>
  
  <pre><code>f = open("test.txt", "w")
  
  for item in test:
      f.write("%s    |    " % item)
  f.close()
  </code></pre>
  
  <p>The result looks like this:</p>
  
  <pre><code>data1, data2, data3, data4, data5, data6, data7, data8......................
  </code></pre>
  
  <p>It should be in this format:</p>
  
  <pre><code>data   |   data2   |   data3   |   data4   |
  data5  |   data6   |   data7   |   data8   |
  data9  |   data10  |   data11  |   data12  |
  </code></pre>
  
  <p>I hope I can have your inputs. Thank you! </p>