Simple newbie question
noemail at noemail4u.com
Fri Dec 5 13:44:38 CET 2003
On Thu, 4 Dec 2003 15:36:11 +0100, Angelo Secchi <secchi at sssup.it>
>I'm trying to remove lines with zeros from a list "lista".
>The code i'm using is the following:
>for line in lista:
> if sum(line == 0) > 0:
>The problem is that the loop stops at the first line with zeros and it
>doesn't remove the other lines with zeros (at least if I do not re-run
>the loop). Probably I do not understand how the loop works.
I see other's responses, but am wondering why the line
if sum(line == 0) > 0:
doesn't raise a "TypeError: iteration over non-sequence" for everyone
else. line==0 is a single boolean, and a sum on that raises an
exception for me.
I'm also wondering why the program compiles, since the
should be more indented.
More information about the Python-list