Answers for "write list of string to txt 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
0

lista to txt python

#Salvar lista em .txt
with open('your_file.txt', 'w') as f:
    for item in my_list:
        f.write("%s\n" % item)
Posted by: Guest on November-27-2020

Python Answers by Framework

Browse Popular Code Answers by Language