title: Python: Putting specific lines of a file into a list
body: <p>Greetings,</p>
  
  <p>i got into the following problem:</p>
  
  <p>Given a file of the following structure:</p>
  
  <pre><code>'&gt;some cookies  
  chocolatejelly  
  peanutbuttermacadamia  
  doublecoconutapple  
  '&gt;some icecream  
  cherryvanillaamaretto  
  peanuthaselnuttiramisu  
  bananacoffee  
  '&gt;some other stuff  
  letsseewhatfancythings  
  wegotinhere  
  </code></pre>
  
  <p>Aim: putting in all entries after every line containing '>' into a list as a single string</p>
  
  <p>Code:</p>
  
  <pre><code>def parseSequenceIntoDictionary(filename):
      lis=[]
      seq=''
      with open(filename, 'r') as fp:
          for line in fp:
              if('&gt;' not in line):
                  seq+=line.rstrip()
              elif('&gt;' in line):
                  lis.append(seq)
                  seq=''
          lis.remove('')
          return lis
  </code></pre>
  
  <p>So this function goes through each line of the file
  if there is not the occurrence of an '>' it concatenates all following lines and removes
  the '\n', 
  if an '>' occurs, it automatically appends the concatenated string to the list and 'clears' the string 'seq' for concatenating the next sequence</p>
  
  <p>The problem:
  To take the example of an input file, it only puts the stuff from 'some cookies' and 'some icecream' into the list - but not from 'some other stuff'. So we get as an result:</p>
  
  <pre><code>[chocolatejelly 
  peanutbuttermacadamia 
  doublecoconutapple, cherryvanillaamaretto 
  peanuthaselnuttiramisu 
  bananacoffee] but not  
  
  [chocolatejelly 
  peanutbuttermacadamia 
  doublecoconutapple, cherryvanillaamaretto 
  peanuthaselnuttiramisu 
  bananacoffee, letsseewhatfancythings 
  wegotinhere]  
  </code></pre>
  
  <p>What is the wrong thought in here? There is some logic mistake in the iteration I may not have taken care, but I do not know where.</p>
  
  <p>Thanks in advance for any hints!</p>