It Doesn't Add Up!
rami.chowdhury at gmail.com
Mon Oct 12 20:38:27 CEST 2009
On Mon, 12 Oct 2009 11:33:31 -0700, Victor Subervi
<victorsubervi at gmail.com> wrote:
> I have the following code:
> for row in data:
> i += 1
> total = 0
> As you can see, the total doesn't accumulate! There are two rows. The
> "Total 1:" should show "1.98", not 0! What gives?
You are setting total = 0 inside the for loop, so it is getting rebound
for every row...
More information about the Python-list