I have a list
[\'Tests run: 1\', \' Failures: 0\', \' Errors: 0\']
I would like to convert it to a dictionary as
{\'Tests r
Try this
In [35]: a = ['Tests run: 1', ' Failures: 0', ' Errors: 0'] In [36]: {i.split(':')[0]: int(i.split(':')[1]) for i in a} Out[36]: {'Tests run': 1, ' Failures': 0, ' Errors': 0} In [37]: