title: Merging elements in a list until certain text appears
body: <p>I have a list like this:</p>
  
  <pre><code>list = ['BHX', 'AR', 'DEFab', 'ABR', 'DEFyr', 'HYt', 'wqw', 'DEF-a']
  </code></pre>
  
  <p>And i want to merge it to look like this:</p>
  
  <pre><code>merged_list = ['BHXAR DEFab', 'ABR DEFyr', 'HYtwqw DEF-a']
  </code></pre>
  
  <p>So basically i want to merge consecutive elements and when phrase 'DEF' is met it's the last element and and every next one creates another element, until again, DEF is met. It definitely looks like place for loop, i've been thinking about something with .append, maybe .next, probably itertools also may be used here, but i don't how to make it work properly.</p>
  
  <p>Also, I'd want to merge elements with no space if none of them contains 'DEF', and with space when last element contains 'DEF'.</p>