Collapse paragraphs

By Hal Canary, 2012-04-03 12:00:00 (link)


#!/usr/bin/env python
# ignores witespace
# collapses paragraphs
import sys
for line in sys.stdin:
    line = line.strip()
    if len(line) == 0:
        sys.stdout.write('\n\n')
    else:
        sys.stdout.write(line+' ')

(back)