Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

how to write lists to text file python

# define list of places
places = ['Berlin', 'Cape Town', 'Sydney', 'Moscow']

with open('listfile.txt', 'w') as filehandle:
    for listitem in places:
        filehandle.write('%s
' % listitem)
Source by stackabuse.com #
 
PREVIOUS NEXT
Tagged: #write #lists #text #file #python
ADD COMMENT
Topic
Name
3+6 =