Don Mahurin commited on
Commit
0543a04
·
1 Parent(s): 9b858a8

Script used to reverse words and punctuation of text.

Browse files
Files changed (1) hide show
  1. wtac.py +16 -0
wtac.py ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/python3
2
+ # reverses word and punctuation order.
3
+ import re
4
+ import sys
5
+
6
+ lines = []
7
+
8
+ for line in sys.stdin:
9
+ #line = " ".join(reversed(line.rstrip().split(" ")))
10
+ line = ''.join(reversed(re.split('([\w\d\']+|\.|"|\?|\!|,)', line.rstrip())))
11
+ lines.append(line)
12
+
13
+ lines.reverse()
14
+
15
+ for line in lines:
16
+ print(line)