Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Systems Design Implementation And Management

Authors: Peter Rob, Carlos Coronel

6th International Edition

061921323X, 978-0619213237

More Books

Students also viewed these Databases questions