Question: file = open(test.txt, w) file.write(This is line 1 This is line 2 This is line 3 ) file.close() file = open(test.txt, r) aString

file = open("test.txt", "w") file.write("This is line 1 " "This is line 2 " "This is line 3 ") file.close() file = open("test.txt", "r") aString = file.read(30) print (aString)

with open("test.txt", "a") as file: file.write("this is the fourth line ") file.close()

I'm able to write to the file and print 2 lines ... but after appending i need to print all the lines

its updating the test file but i need to print out all of it

Output should be:

#This is line 1 #This is line 2 #This is line 3 #this is the fourth line

in Python

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!