Python File I/O: Write a List content to a file
Python File I/O: Exercise-12 with Solution
Write a Python program to write a list content to a file.
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())
Red Green White Black Pink Yellow
Python Code Editor:
Improve this sample solution and post your code through Disqus