[Tutor] Matching zipcode in address file
galaxywatcher at gmail.com
Tue Apr 6 04:47:56 CEST 2010
I got it. I was comparing '345' to '345\n'
Adding the '\n' to the slice did indeed do the trick.
infile = open("filex")
outfile = open("results_testx", "w")
zips = open("zippys", "r")
match_zips = zips.readlines()
lines = [line for line in infile if (line[0:3] + '\n') in
# print lines[0:2]
More information about the Tutor