Answered step by step
Verified Expert Solution
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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started