Change array that might contain None to an array that contains "" in python
Posted
by vy32
on Stack Overflow
See other posts from Stack Overflow
or by vy32
Published on 2010-05-28T20:30:42Z
Indexed on
2010/05/28
20:42 UTC
Read the original article
Hit count: 261
python
|string-manipulation
I have a python function that gets an array called row.
Typically row contains things like:
["Hello","goodbye","green"]
And I print it with:
print "\t".join(row)
Unfortunately, sometimes it contains:
["Hello",None,"green"]
Which generates this error:
TypeError: sequence item 2: expected string or Unicode, NoneType found
Is there an easy way to replace any None elements with ""?
© Stack Overflow or respective owner