[Tutor] File operation query

Reuben reuben.dlink at gmail.com
Thu Oct 15 12:00:09 EDT 2015


Hi All,

I need some clarification for below code. In line 2 of below code snippet,
I have provided read and write permission. Assuming I have provided some
string input as requested in line 1 - when I try to open "check.txt" file
after running the script, it is always empty - it does not display the user
input provided.

May I know why?

######################################################################

input1 = raw_input("Input1:")


file = open("check.txt", "r+")

file.write(input1 + "\n")


for line in file:
        print line


print file.close()

######################################################################


Regards,
RD.


More information about the Tutor mailing list