help with lists and writing to file in correct order

bonono at gmail.com bonono at gmail.com
Tue Dec 27 00:05:07 EST 2005


homepricem... at gmail.com wrote:
> sorry for asking such beginner questions but i tried this and nothing
> wrote to my text file
>
> for food, price, store in bs(food, price, store):
> 		out = open("test.txt", 'a')
> 		out.write (food + price + store)
>         	                out.close()
>
>
> while if i write the following without the for i at least get
> something?
> out = open("test.txt", 'a')
> out.write (food + price + store)
> out.close()
>
pull the open() and close() call out of the loop. And use some other
name for the variables as they are very confusing and could be error
prone to.




More information about the Python-list mailing list