[Tutor] Matching zipcode in address file
alan.gauld at btinternet.com
Tue Apr 6 09:45:26 CEST 2010
"TGW" <galaxywatcher at gmail.com> wrote
>I got it. I was comparing '345' to '345\n'
> Adding the '\n' to the slice did indeed do the trick.
Yes, the problem is that the data in the file always has a \n at the end.
So you either have to rstrip() that off when you read it from the file
or add a \n to your source data when comparing it with file data.
Personally I usually use strip() so that I'm working with 'clean' data
both for source and reference.
Author of the Learn to Program web site
More information about the Tutor