comparison reverse_lines.py @ 1:068e3e9935c1 default tip

removed the part of reading a local data file
author nvskarunakar@gmail.com
date Fri, 13 Jun 2014 14:15:40 +0530
parents 010446674569
children
comparison
equal deleted inserted replaced
0:010446674569 1:068e3e9935c1
1 import sys 1 import sys
2 2
3 def string_reverse(text): 3 def string_reverse(text):
4 return text[::-1] 4 return text[::-1]
5 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() 6 lines = sys.stdin.read().splitlines()
14 for i, line in enumerate(lines): 7 for i, line in enumerate(lines):
15 print string_reverse(line); 8 print string_reverse(line);