Answers for "how to write a txt to a list file in python"

7

convert python list to text file

# 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-20-2020

Code answers related to "how to write a txt to a list file in python"

Python Answers by Framework

Browse Popular Code Answers by Language