Re: It Doesn't Add Up!

2009-10-13 Thread Stephen Hansen
On Mon, Oct 12, 2009 at 11:33 AM, Victor Subervi wrote: > for row in data: > i += 1 > total = 0 > quantity = form.getfirst('order_' + str(i), '') > if quantity != '': > sql = 'select * from products p join %s c on p.ID=c.ID where > c.ID=%s;' % (client, str(i)) >

Re: It Doesn't Add Up!

2009-10-12 Thread MRAB
Victor Subervi wrote: Hi; I have the following code: [snip] price = str(int(stuff[5]*100)) price = price[0:len(price)-2] + '.' + price[-2:] [snip] This is simpler: price = "%.2f" % stuff[5] (not that I like what you're doing with it; leaving it as a float and just fo

Re: It Doesn't Add Up!

2009-10-12 Thread Victor Subervi
Ouch! You're right! <;) V On Mon, Oct 12, 2009 at 1:38 PM, Rami Chowdhury wrote: > On Mon, 12 Oct 2009 11:33:31 -0700, Victor Subervi < > victorsube...@gmail.com> wrote: > > Hi; >> I have the following code: >> >>for row in data: >> i += 1 >> total = 0 >> > [snip] > >> As you can

Re: It Doesn't Add Up!

2009-10-12 Thread Rami Chowdhury
On Mon, 12 Oct 2009 11:33:31 -0700, Victor Subervi wrote: Hi; I have the following code: for row in data: i += 1 total = 0 [snip] As you can see, the total doesn't accumulate! There are two rows. The second "Total 1:" should show "1.98", not 0! What gives? You are sett

Re: It Doesn't Add Up!

2009-10-12 Thread Chris Kaynor
Chris On Mon, Oct 12, 2009 at 11:33 AM, Victor Subervi wrote: > Hi; > I have the following code: > > for row in data: > i += 1 > total = 0 > In the above line, you're setting total to 0 each time the loop runs. > quantity = form.getfirst('order_' + str(i), '') > if