title: Python dictionary - find key in next line
body: <p>I created dictionary from email body</p>
  
  <pre><code>print email body
  
  Application name: dummy.service
  Source: host2
  Timestamp: 2019-01-23T22:00:01.026Z
  Message: LivePnL:in live pricing
  
  
  Application name: dummy.service
  Source: host2
  Timestamp: 2019-01-23T22:00:01.016Z
  Message: Risk request failed
  
  
  Application name: dummy.service
  Source: host2
  Timestamp: 2019-01-23T22:00:00.994Z
  Message: Risk request failed
  </code></pre>
  
  <p>if all above is in same line, i can get Application name, Source and Message, but if Source and Message are in new line i can get only Application name</p>
  
  <p>above variable (email body) is input of below function</p>
  
  <pre><code>def parse_subject(line):
      info = {}
      segments = line.split(' ')
  
      info['time'] = segments
      for i in range(2, len(segments)):
          key = ''
          if segments[i] == 'Application Name:':
              key = 'alarm'
          elif segments[i] == 'Source:':
              key = 'job'
          elif segments[i] == 'Message:':
              key = 'machine'
          if key != '':
              i += 1
              info[key] = segments[i]
      return info
  
  
   if mail["Subject"].find("Alert for dummy services errors") &gt; 0 :
             body = get_autosys_body(mail)
          for line in body.splitlines():
                if 'Application name' in line:
                  job_info = parse_subject(line)
                  break
          print (job_info)
  </code></pre>
  
  <p>job info currenly gives me only key from first line</p>
  
  <pre><code>{'time': ['Application', 'name:', 'dummy.service']}
  </code></pre>
  
  <p>how to get values after Source and Message ? or how to put lines in email_body into single line ?</p>