programming-examples/python/Input_Output/Python program to write a list content to a file.py

7 lines
230 B
Python
Raw Normal View History

2019-11-15 12:59:38 +01:00
color = ['Red', 'Green', 'White', 'Black', 'Pink', 'Yellow']
with open('abc.txt', "w") as myfile:
for c in color:
myfile.write("%s\n" % c)
content = open('abc.txt')
print(content.read())