I have a list
[\'Tests run: 1\', \' Failures: 0\', \' Errors: 0\']
I would like to convert it to a dictionary as
{\'Tests r
a = ['Tests run: 1', ' Failures: 0', ' Errors: 0'] b = dict([i.split(': ') for i in a]) final = dict((k, int(v)) for k, v in b.items()) # or iteritems instead of items in Python 2 print(final)
{' Failures': 0, 'Tests run': 1, ' Errors': 0}