I have a list
[\'Tests run: 1\', \' Failures: 0\', \' Errors: 0\']
I would like to convert it to a dictionary as
{\'Tests r
Loop over your list, and split by the colon. Then assign the first value to the second value in a dict object:
x = ['Tests run: 1', ' Failures: 0', ' Errors: 0']
y = {}
for k in x:
c = k.split(':')
y[str(c[0]).replace(" ", "")] = str(c[-1]).replace(" ", "")
print(y)
#{'Failures': '0', 'Tests run': '1', 'Errors': '0'}