problem with lists
Manuel Hendel
python-list at hendel.net
Wed Sep 11 17:54:23 EDT 2002
I want to create a list of domains, every domain only once.
So long I did the following, but it didn't work:
#!/usr/bin/env python
#
import sys, string, re
inputfile = open(sys.argv[-1], "r")
lines = inputfile.readlines()
lines = lines[3:]
for line in lines:
line = string.strip(line)[1:-1]
fields = string.split(line, "|")
domains = []
if not domains.index(fields[3:4]):
domains.append(fields[3:4])
print domains
This brings the following error message:
:!./pop3create.py pop3data
[No write since last change]
Traceback (most recent call last):
File "./pop3create.py", line 22, in ?
if domains.index(fields[3:4]):
ValueError: list.index(x): x not in list
Can someone explain this to me?
Thanks,
Manuel
--
Immature love says, "I love you because I need you." Mature love says, "I need
you because I love you."
-Erich Fromm
More information about the Python-list
mailing list