Question 5 Write a method in Python to write multiple lines of text
contents into a text file, ''MYFILE.TXT'' line.
declaring function count( )
Taking a user input as ‘line’ for writing it to the file.
Invoking function write( )
opening the text file in read mode and assigning it to file_object ‘f’
Writes ‘line’ to the text file.
Output
Made by
Davneet Singh
Davneet Singh is an IIT Kanpur graduate and has been teaching for 16+ years. At Teachoo, he breaks down Maths, Science and Computer Science into simple steps so students understand concepts deeply and score with confidence.
Many students prefer Teachoo Black for a smooth, ad-free learning experience.
It looks like you're using AdBlock
Don't be a miser! Join Teachoo Black at ₹19 only to view the ad-free version of Teachoo.
Please login to view more pages. It's free :)
Teachoo gives you a better experience when you're logged in. Please login :)