Reputation: 45
When i create and write in a text file using the python code below, it executes successfully. However, when i open the text file, it does not show anything written in it!
newl=[]
print ""
while 1:
tks=raw_input("# ")
if tks=="/":
text=''.join(newl)
print text
filen=open('c:/Users/Admin/Desktop/snickcode.txt', 'w')
filen.write(str(text))
filen.close
print "#saved to desktop, please rename the file before reuse"
print "{non}"
print ""
break
else:
gig=(str(tks))
newl.append(gig)
print newl
Upvotes: 0
Views: 50
Reputation: 43314
I assume /
is the first input you tried.
Because this
text=''.join(newl)
...
filen.write(str(text))
is what you write you the file and
newl=[]
doesn't contain any items at that point, the contents of the file remain 'empty'.
Upvotes: 1