Apr-20-2020, 03:56 AM
I assume you are talking about the print ("All Lines -->>…
Initially 'st+t1, endt1, rnt_1, and prg_n are all ' '. If runtime_l is encountered before start_tm or end_tm or program_n, the print statement will print a bunch of blanks. Moving the "if program_n in ln: does nothing to change the logic of the program. It should act exactly the same way. However you also moved the print from one "if" to another. I can only guess, but I think you want to have the print statement outside the for loop. That way it will wait for all lines to be processed before printing.
By the way, the "ftow.close)_" is not needed. The "with open..." creates a context for the file. When the program exits the context the file automatically closes. It would even close if there was an exception that caused the program to fail.
Initially 'st+t1, endt1, rnt_1, and prg_n are all ' '. If runtime_l is encountered before start_tm or end_tm or program_n, the print statement will print a bunch of blanks. Moving the "if program_n in ln: does nothing to change the logic of the program. It should act exactly the same way. However you also moved the print from one "if" to another. I can only guess, but I think you want to have the print statement outside the for loop. That way it will wait for all lines to be processed before printing.
By the way, the "ftow.close)_" is not needed. The "with open..." creates a context for the file. When the program exits the context the file automatically closes. It would even close if there was an exception that caused the program to fail.