On May 16, 9:41 am, stef <[EMAIL PROTECTED]> wrote:
> hello,
>
> can someone tell me why the following iteration doesn't work,
> and
> how I should replace empty strings in a list with a default value.

See the other reponse for the why. Here's another how, using list
comprehension.:

1 > v = ['123', '345', '', '0.3']
2 > v = [x if x else '3' for x in v]
3 > v
3 = ['123', '345', '3', '0.3']

Note that this replaces the list, so won't be appropriate for
modifying a list passed in from elsewhere.

--
Ant...

http://antroy.blogspot.com/


-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to