fork download
  1. import re
  2. import sys
  3.  
  4. names = [
  5. 'Problem Category',
  6. 'Problem Subcategory',
  7. 'Problem Type',
  8. 'Software Version',
  9. 'Problem Details']
  10.  
  11. text = sys.stdin.read()
  12.  
  13. pat = r'({}):'.format('|'.join(map(re.escape, names)))
  14. data = dict(zip(*[iter(re.split(pat, text, re.MULTILINE)[1:])]*2))
  15.  
  16. from pprint import pprint
  17. pprint(data)
Success #stdin #stdout 0.04s 9696KB
stdin
Problem Category: Human Endeavors Problem Subcategory: Space ExplorationProblem Type: Failure to LaunchSoftware Version: 9.8.77.omni.3Problem Details: Issue with signal barrier chamber.
stdout
{'Problem Category': ' Human Endeavors ',
 'Problem Details': ' Issue with signal barrier chamber.',
 'Problem Subcategory': ' Space Exploration',
 'Problem Type': ' Failure to Launch',
 'Software Version': ' 9.8.77.omni.3'}