Exercise 1: Write a Python program that reads from the user the name of two files (an input file and an output file). The program will then read each line of the input file and save it in the output file preceded with the line number and removing any of the following punctuations (. , !?; :) found at the end of the line. For example, if the input file is: Mary had a little lamb; Whose fleece was white as snow; And everywhere that Mary went; The lamb was sure to go! Then the output file the content of the input file and saves it in the produced output file will be Line 1: Mary had a little lamb Line 2: Whose fleece was white as snow Line 3: And everywhere that Mary Line 4: The lamb was sure to go
Write a Python
Mary had a little lamb;
Whose fleece was white as snow; And everywhere that Mary went; The lamb was sure to go!
Then the output file the content of the input file and saves it in the produced output file will be
Line 1: Mary had a little lamb
Line 2: Whose fleece was white as snow Line 3: And everywhere that Mary
Line 4: The lamb was sure to go
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 3 images