Re: [Tutor] Searching a text file's contents and comparing them to a list

2010-07-14 Thread Emile van Sebille
On 7/14/2010 9:22 AM Eric Hamiter said... Fantastic! I have this, which now works. Is there a better place to put string.strip? I might make the changes below, but there's nothing wrong with the way you've got it. aisle_one = ["chips", "bread", "pretzels", "magazines"] grocery_list = open

Re: [Tutor] Searching a text file's contents and comparing them to a list

2010-07-14 Thread Eric Hamiter
Fantastic! I have this, which now works. Is there a better place to put string.strip? aisle_one = ["chips", "bread", "pretzels", "magazines"] grocery_list = open("grocery_list.txt", "r") for line in grocery_list.readlines(): if line.strip() in aisle_one: print "success! i found %s" % l

Re: [Tutor] Searching a text file's contents and comparing them to a list

2010-07-14 Thread Emile van Sebille
On 7/14/2010 8:46 AM Eric Hamiter said... Hi all, New programmer here. This is what I want to do: 1. Open an existing text file named "grocery_list.txt", which has one item per line, like so: butter juice bread asparagus magazines ice cream 2. ...and search for these items in a pre-defined li

[Tutor] Searching a text file's contents and comparing them to a list

2010-07-14 Thread Eric Hamiter
Hi all, New programmer here. This is what I want to do: 1. Open an existing text file named "grocery_list.txt", which has one item per line, like so: butter juice bread asparagus magazines ice cream 2. ...and search for these items in a pre-defined list. But I can't seem to get this working. R