Confused compare function :)

Neil Cerutti neilc at norwich.edu
Thu Dec 6 08:51:29 EST 2012


On 2012-12-06, Steven D'Aprano
<steve+comp.lang.python at pearwood.info> wrote:
> total = 0
> for s in list_of_strings:
>     try:
>         total += int(s)
>     except ValueError:
>         pass  # Not a number, ignore it.

If it's internal data, perhaps. Of course, that would mean I had
the option of *not* creating that stupid list_of_strings.

-- 
Neil Cerutti



More information about the Python-list mailing list