Help with cumulative sum

Andreas Waldenburger usenot at geekmail.INVALID
Tue Sep 8 22:31:21 CEST 2009


On Tue, 8 Sep 2009 13:23:43 -0700 (PDT) Maggie <la.foma at gmail.com>
wrote:

> On Sep 8, 4:17 pm, MRAB <pyt... at mrabarnett.plus.com> wrote:
> [snip] 
> I saw my mistake...now it is telling me the following --
> 
> Traceback (most recent call last):
>   File "formisano_count.py", line 22, in <module>
>     running_sum = running_sum + (int(item) * int(item))
> ValueError: invalid literal for int() with base 10: ''
> ..
> not sure what exactly i am doing wrong!

What this error means is that the int() constructor is passed an empty
string (''). So there is probably an empty line in your input file.

You can catch these with a simple

if item:
    # usual code goes here

/W


-- 
INVALID? DE!




More information about the Python-list mailing list