I am trying to output a list of addresses that do not match a list of
State abbreviations. What I have so far is:
def main():
infile = open("list.txt", "r")
for line in infile:
state = line[146:148]
omit_states = ['KS', 'KY', 'MA', 'ND', 'NE', 'NJ', 'PR',
'RI', 'SD', 'VI', 'VT', 'WI']
for n in omit_states:
if state != n:
print line
infile.close()
main()
This outputs multiple duplicate lines. The strange thing is that if I
change 'if state == n:' then I correctly output all matching lines.
But I don't want that. I want to output all lines that do NOT match
the States in the omit_states list.
I am probably overlooking something very simple. Thanks in advance.
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor