0

I intend to append following list into a csv file so that it appears in a single row but my code isn't working. I'm a beginner in python. Any suggestions would be welcome. Thank You.

list_one = ['apple','ball','cat','dog']

I tried following code:

import csv

list = ['apple','cat','dog']

with open('document.csv','a') as fd:
  fd.writerows(list)
  • 1
    Does this answer your question? [Writing a Python list of lists to a csv file](https://stackoverflow.com/questions/14037540/writing-a-python-list-of-lists-to-a-csv-file) – depperm Oct 07 '21 at 11:30

1 Answers1

2
import csv

list = ['apple','cat','dog']

with open('document.csv','a') as fd:
  write = csv.writer(fd)   
  write.writerow(list)

Dean Taler
  • 737
  • 1
  • 10
  • 25