lists + string

ian iwaters at btclick.com
Fri May 10 13:08:41 EDT 2002


cheers for the quick response
what im doing is reading a line from a file
then appending it to my wordlist list.
how would i do it knowing this???

word = str(raw_input("Enter word to remove: "))

wordlist = []
    spamfile = file('spam.txt','r',1024)

    while 1:
     line = spamfile.readline(1024)
     if line == '':break
     wordlist.append(line)
    spamfile.close()

    #write back file
    #spamfile = file('spam.txt','w+',1024)
    print "word list"
    for x in wordlist:
     print x
     if x == word:print 'found'
     #spamfile.write(x)
    #spamfile.close()


"ian" <iwaters at btclick.com> wrote in message
news:UORC8.49610$7R.60091 at NewsReader...
> hi started to learn python this week
> and my lecturer threw us in the deep end
> and asked us to write a mail server.. oh well
>
> anyway in the program i read in some input from the user
>
> input = str(raw_input .........
>
> how do i compare it to an element in a list??
>
> ive tried
>
> for x in list
>     if input == x:print 'found item'
>
> but it dont work any help would be great thanx
>
>





More information about the Python-list mailing list