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("grocery_list.txt", "r")
grocery_list= [ item.strip() for item in open("grocery_list.txt", "r").readlines() ]
for line in grocery_list.readlines():
for item in grocery_list:
if line.strip() in aisle_one:
if item in aisle_one:
print "success! i found %s" % line else: print "no joy matching %s" % line grocery_list.close()
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor