title: Python - can split() command be indexed?
body: <p>I am trying to parse and split the line:</p>
  
  <pre><code>redfish - 12,000 lbs - trade for SNE stocks
  </code></pre>
  
  <p>The code I'm trying is:</p>
  
  <pre><code>elif ('-' in line) and ('lbs' in line):
      fish, remainder = line.split('-')               #splits line into two halves at the - (fish to one side)
      #print("line.split is:", line.split(':'))
      if '@' in remainder:
          weight, price = remainder.split('@')        #splits already split piece (remainder) into two halves at @
          if '--&gt;' in price:
              price, junk = price.split('--&gt;')
      if 'trade' in remainder:
          if 'to ' in remainder:
              weight, price = remainder.split('to ')
          elif ' or ' in remainder:
              weight, price = remainder.split(' or ') #add spaces around ' or ' so we don't match 'for'
      if 'swap' in remainder:
          weight, price = remainder.split('to ')
  </code></pre>
  
  <p>It fails on the line:</p>
  
  <p><code>fish, remainder = line.split('-')</code> </p>
  
  <p>with the error:</p>
  
  <p><code>ValueError: too many values to unpack (expected 2)</code>. </p>
  
  <p>Now I know this is due to the fact that there are 2 <code>'-'</code> in that line and Python doesn't know which one to split on, so I tried telling it to split on the first <code>'-'</code> with: <code>fish, remainder = line.split('-'[0])</code> but that fails. </p>
  
  <p>So my question is: is there a way around this? Can I index the <code>split()</code> command another way so that I can successfully split that line like I want to?</p>
  
  <p>Thanks for any help or tips.</p>