[Tutor] Tutor Digest, Vol 38, Issue 1

Rikard Bosnjakovic rikard.bosnjakovic at gmail.com
Sun Apr 1 14:28:36 CEST 2007


On 4/1/07, Jay Mutter III <jmutter at uakron.edu> wrote:

> For some reason this never works for me;

That's because you are ignoring the linefeed character:

[...]
>      if line.endswith('No.'):

>>> s1 = "some line\n"
>>> s2 = "some line"
>>> s1.endswith("line"), s2.endswith("line")
(False, True)

Just skip the if and simply rstrip the string.


-- 
- Rikard - http://bos.hack.org/cv/


More information about the Tutor mailing list