You can number the lines in a file using a simple Python program. Here's an example:
<code class="language-python">with open('input.txt', 'r') as infile, open('output.txt', 'w') as outfile:
for line_number, line in enumerate(infile, start=1): outfile.write(f"{line_number}: {line}")
</code>
This code reads from input.txt, numbers each line, and writes the numbered lines to output.txt. The enumerate function is used to keep track of the line numbers, starting from 1.
Copyright © 2026 eLLeNow.com All Rights Reserved.