• + 3 comments

    First, the strip() in the input line just messes things up by confusing the zip(), so I took that out; then, after the append() loop, I did this:

    print(sub(r'(\w)(\W)+(\w)',
              r'\1 \3',
              ''.join([u for t in zip(*matrix) for u in t])))