Simple I/O problem can't get solved

Jussi Piitulainen jpiitula at ling.helsinki.fi
Fri Jun 21 05:11:38 EDT 2013


nickgan.sps at windowslive.com writes:

> I think I coded it correctly but still I get no output. I do not
> have any errors I just do not get any output.
> 
> This is the code:
> 
> ***
> import is_palindrome
> 
> filename = raw_input('Enter a file: ') # A text file
> f = open(filename)
> while True:
> 	line = f.readline()
> 	if len(line) == 0:
> 		break
> 	elif is_palindrome.is_palindrome(line):	
> 		print line,
> f.close()

There's a newline at the end of each input line. Strip that. (It might
be another sequence that means end-of-line in your system. It can
still be stripped as trailing whitespace. Strings have a method for
stripping trailing whitespace.)



More information about the Python-list mailing list