How to replace all None values with the string "Null" in a dictionary
bruno at modulix
onurb at xiludom.gro
Fri Oct 28 05:01:39 EDT 2005
dcrespo wrote:
> Hi all,
>
> How can I replace all None values with the string 'Null' in a
> dictionary?
>
> For example:
> convert this:
> a = {'item1': 45, 'item2': None}
>
> into this:
> a = {'item1': 45, 'item2': 'Null'}
>
I think it would be time for you to read the Fine Manual...
for key in a:
if a[key] is None:
a[key] = 'Null'
--
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in 'onurb at xiludom.gro'.split('@')])"
More information about the Python-list
mailing list