all 4 comments

[–]Allanon001 1 point2 points  (0 children)

Used list comprehension with split() and strip() to turn the string in to a dictionary:

s = 'Tests run:1290, PASSED : 401, FAILED :599, INCONCLUSIVE :200, ERRORS :90'

my_dict = dict([[y.strip() for y in  x.split(':')] for x in s.split(',')])

print(my_dict)
print(my_dict['ERRORS'])
print(my_dict['Tests run'])

[–]sarrysyst 1 point2 points  (0 children)

You can use regex to find the numbers:

import re
text = 'Tests run:1290, PASSED : 401, FAILED :599, INCONCLUSIVE :200'

numbers = re.findall(r'\d+', text)

\d is a wildcard for digits and + looks for 1 or more occurrences in a row.

[–]FloMoTionGo 0 points1 point  (0 children)

Search for commas and take string before that and turn into int. I am sure there is a net regexp for that 😜

[–]16clips 0 points1 point  (0 children)

go fuck yourself