replace value in list of dictionaries python code example

replace value in list of dictionaries python

1

1 Example

0
for dict in clean_dict:
    for k,v in dict.items():
        if v == '*':
            dict[k] = 4
        elif v == '':
            dict[k]= 0
        else:
            # not necessarily an integer so handle exception
            try:
                dict[k] = int(v)
            except ValueError:
                pass
by on

Other Code Examples