[Tutor] find() doesnt work as expected
Alan Gauld
alan.gauld at btinternet.com
Sat Jan 2 10:22:18 CET 2010
"MK" <lopoff at gmx.net> wrote
> I tried this but it gives nothing out:
Try putting some debug print statements in - for example
print the option filenames to prove you got them ok,
print progress markers like adfter opening the files
Then print a message for each string found..
> for a in infi:
> found = ftck_datei.find(a)
One thing you probably need to do is strip() the newline character
from the end of a. Otherwise you will be searching for strings
ending in newline. But if that were the problem all the tests
should fail and you should get a lot of output!
> if found==-1:
It is more readable if you put some spaces in!
if found == -1:
HTH,
--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/
More information about the Tutor
mailing list