Skip to content

Commit 62c8f6f

Browse files
committed
Program to write a list to file
1 parent 220f043 commit 62c8f6f

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

ListToFile.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#write a list to file
2+
color = ['Red', 'Green', 'White', 'Black', 'Pink', 'Yellow']
3+
with open('abc.txt', "w") as myfile:
4+
for c in color:
5+
myfile.write("%s\n" % c)
6+
7+
content = open('abc.txt')
8+
print(content.read())

0 commit comments

Comments
 (0)