You already know how to store multiple vars -- use lists! Just create a blank
one before your loop and append() to it. Also you might think of a generic way
to do this without relying on separate variables for each aisle, what if your
store has 30 aisles? Hint: lists can contain any python objec
Follow-up question: My code is now this:
aisle_one = ["chips", "bread", "pretzels", "magazines"]
aisle_two = ["juice", "ice cream"]
aisle_three = ["asparagus"]
def find_groceries():
grocery_list = open("grocery_list.txt", "r")
for line in grocery_list.readlines():
line = line.stri
On Wed, Jul 14, 2010 at 12:26 PM, Alan Gauld wrote:
>
> If you never need a stripped version of line again, or if you
> are planning on writing it out to another file then this is fine.
> If you are going to use it again its probably better to strip()
> and asign to itelf:
>
> line = line.strip()
"Eric Hamiter" wrote
Fantastic! I have this, which now works. Is there a better place to
put
string.strip?
Its largely a matter of taste and how you intend using the value.
aisle_one = ["chips", "bread", "pretzels", "magazines"]
grocery_list = open("grocery_list.txt", "r")
for line in gr