title: Writing List to a csv file in Python
body: <p>I'm currently using Python v2.10.  I'm having trouble writing data to a csv file.  Wondering if someone might be able to tell me what I am doing wrong.  I'm getting the following error: <code>"TypeError: list indices must be integers, not tuple"</code> - not sure how to correct this.  Also, I thought to write to a csv file, the data must be in string format ?</p>
  
  <p>Ideally I would like each row to be like:
  Name, X1, Y1, X2, Y2, X3, Y3</p>
  
  <p>Here is the code I have:</p>
  
  <pre><code>import csv
  
  def main():
      my_coords = open('Geo_Coords.csv', 'a')
      coords = csv.reader(my_coords)
  
      how_many = raw_input("How many Geometries do you wish to enter? ")
      counter = 0
      coords = []
  
      while counter &lt; how_many:
          geometry = raw_input("Geometry Name  ")
          first_coordE = raw_input("1st Co-ord (Easting) ")
          first_coordN = raw_input("1st Co-ord (Northing) ")
          sec_coordE = raw_input("2nd Co-ord (Easting) ")
          sec_coordN = raw_input("2nd Co-ord (Northing) ")
          third_coordE = raw_input("3rd Co-ord (Easting) ")
          third_coordN = raw_input("3rd Co-ord (Northing) ")
          counter = counter + 1
  
          my_coords.write(coords[[geometry],[first_coordE,first_coordN], [sec_coordE,sec_coordN], [third_coordE,third_coordN]] )
  
      my_coords.close()
      print my_coords
  
  main()
  </code></pre>