Skip to content

Instantly share code, notes, and snippets.

@tkellogg
Created December 28, 2024 02:43
Show Gist options
  • Save tkellogg/f4ec3fcce669c4f75ceabffce79b157b to your computer and use it in GitHub Desktop.
Save tkellogg/f4ec3fcce669c4f75ceabffce79b157b to your computer and use it in GitHub Desktop.
numcat: Prepent line numbers
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