My small script returns a comma separated list of 10 floating point values, loops through them, and holds them in variable vals.
I sum these up into new variable 'total' like this:
total = sum(map(float, vals))
Easy enough, BUT oftentimes None occurs as one or more values in the list,
4.234,None,0.2398,None,None,0.0166666666667,None,None,None,None
then I get the ValueError:
ValueError: could not convert string to float: N
How can I convert these None values to 0 so that the values sum up without error?
Nonewith0. I wonder if there a better wayvalsis a string, not a list. Is that correct?