File Handling | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

File Handling

x=open ('file.txt', 'w') x.write('hello') x.close() when I run the above code it is throwing an error saying write is not defined.....I'm using python 3.6....please help me

17th Jul 2019, 8:47 AM
Uthpala
3 Answers
+ 3
It works for me. Try this. x=open ('file.txt', 'w') x.write('hello') x.close() y = open('file.txt') print(y.read()) y.close() # Output is hello
20th Jul 2019, 6:12 AM
David Ashton
David Ashton - avatar
0
I have the same problem try using anaconda distribution. In anaconda distribution all these work
17th Jul 2019, 12:24 PM
Chaitanya Damaraju
Chaitanya Damaraju - avatar
0
Thanks @Chaitanya
19th Jul 2019, 11:05 AM
Uthpala