Created
October 1, 2024 09:35
-
-
Save OhadRubin/73ad80ad6b1b04bb9dc4b0973c21ba19 to your computer and use it in GitHub Desktop.
add_line_numbers.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def add_line_numbers(input_file, output_file): | |
with open(input_file) as f: | |
text = f.read() | |
output_text = "\n".join([f"{i} {line}" for i, line in list(enumerate(text.split("\n")))]) | |
with open(output_file, "w") as f: | |
f.write(output_text) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment