changeset 0:010446674569

first draft
author nvskarunakar@gmail.com
date Fri, 13 Jun 2014 14:13:18 +0530
parents
children 068e3e9935c1
files reverse_lines.py
diffstat 1 files changed, 15 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/reverse_lines.py	Fri Jun 13 14:13:18 2014 +0530
@@ -0,0 +1,15 @@
+import sys
+
+def string_reverse(text):
+    return text[::-1]
+	
+f = open('data')
+lines = f.read().splitlines()
+f.close()
+
+for i, line in enumerate(lines):
+    print "{line} becomes {reversed_line}".format(line=line, reversed_line=string_reverse(line));
+
+lines = sys.stdin.read().splitlines()
+for i, line in enumerate(lines):
+    print string_reverse(line);