# 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)
a_list = ["abc", "def", "ghi"]
f = open("a_file.txt", "w")
for item in a_list:
f.write(item + "
")
f.close()
# 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)
data = [1,2,3,4,5]
with open('myfile.txt', 'w') as f:
f.writelines([f"{x}
" for x in data])
all_sents = ['hey there', 'how are you']
with open('file_name.txt', 'w', encoding='utf-8') as f:
f.write('
'.join(all_sents))
with open('your_file.txt', 'w') as f:
for line in lines:
f.write(f"{line}
")