Ask Question
21 January, 19:04

Write a script named numberlines. py. This script creates a program listing from a source program. This script should: Prompt the user for the names of two files. The input filename could be the name of the script itself, but be careful to use a different output filename! The script copies the lines of text from the input file to the output file, numbering each line as it goes. The line numbers should be right-justified in 4 columns, so that the format of a line in the output file looks like this example: 1> This is the first line of text

+1
Answers (1)
  1. 21 January, 22:30
    0
    See explaination for program code.

    Explanation:

    inputFileName = input ("Input filename: ") outputFileName = input ("Output filename: ") inputFile = open (inputFileName, "r") outputFile = open (outputFileName, "w") count = 1 for line in inputFile: newLine = str (count). rjust (4, " ") + "> " + line outputFile. write (newLine) print (newLine) count + = 1
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Write a script named numberlines. py. This script creates a program listing from a source program. This script should: Prompt the user for ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers