Created
December 28, 2024 02:43
-
-
Save tkellogg/f4ec3fcce669c4f75ceabffce79b157b to your computer and use it in GitHub Desktop.
numcat: Prepent line numbers
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
import sys | |
def prepend_line_numbers(): | |
for line_number, line in enumerate(sys.stdin, start=1): | |
# Remove trailing newline character if present | |
stripped_line = line.rstrip('\n') | |
print(f"{line_number}: {stripped_line}") | |
if __name__ == "__main__": | |
prepend_line_numbers() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment