Advertisements
Advertisements
Question
Write a command(s) to write the following lines to the text file named hello.txt. Assume that the file is opened in append mode.
“ Welcome my class”
“It is a fun place”
“You will learn and play”
Short/Brief Note
Advertisements
Solution
Assumed this statement, as stated in question -
filehandle = open("hello.txt","a")
commands to write following lines are -
1 file_handle = open("hello.txt", "a")
2 file_handle.write("Welcome my class")
3 file_handle.write("It is a fun place")
4 file_handle.write("you will learn and play")
5 file_handle.close()shaalaa.com
Opening and Closing a Text Files in Python
Is there an error in this question or solution?
