I have a list
[\'Tests run: 1\', \' Failures: 0\', \' Errors: 0\']
I would like to convert it to a dictionary as
{\'Tests r
l = ['Tests run: 1', ' Failures: 0', ' Errors: 0'] d = dict([map(str.strip, i.split(':')) for i in l]) for key, value in d.items(): d[key] = int(value) print(d)
output:
{'Tests run': 1, 'Errors': 0, 'Failures': 0}