Answers for "how to save a list in a text file python"

1

list to text file python

with open('your_file.txt', 'w') as f:
    for item in my_list:
        f.write("%s\n" % item)
Posted by: Guest on January-05-2021
3

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\n' % listitem)
Posted by: Guest on August-01-2020

Code answers related to "how to save a list in a text file python"

Python Answers by Framework

Browse Popular Code Answers by Language