Mercurial > repos > nvskarunakar > file_utils
comparison reverse_lines.py @ 0:010446674569
first draft
author | nvskarunakar@gmail.com |
---|---|
date | Fri, 13 Jun 2014 14:13:18 +0530 |
parents | |
children | 068e3e9935c1 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:010446674569 |
---|---|
1 import sys | |
2 | |
3 def string_reverse(text): | |
4 return text[::-1] | |
5 | |
6 f = open('data') | |
7 lines = f.read().splitlines() | |
8 f.close() | |
9 | |
10 for i, line in enumerate(lines): | |
11 print "{line} becomes {reversed_line}".format(line=line, reversed_line=string_reverse(line)); | |
12 | |
13 lines = sys.stdin.read().splitlines() | |
14 for i, line in enumerate(lines): | |
15 print string_reverse(line); |