title: Removing and replacing coefficients of polynomials in Python
body: <p>I´m having some trouble using python´s list function for polynomials. </p>
  
  <p>For example, if I write the poynomial <code>p1  = [0, 0, 0, 1, 1]</code>, I get the output <code>1*x^4 + 1*x^3 + 0*x^2 + 0*x + 0</code></p>
  
  <p>I want to adjust this so that:</p>
  
  <ul>
  <li><p>Terms with coefficient 1 are written without the coefficients, e.g. <code>"1x^3"</code> should be written as <code>"x^3"</code>.</p></li>
  <li><p>Terms with coefficient 0 should not be written at all, e.g. <code>"x^4 + x^3 + 0*x^2 + 0*x + 0"</code> should be simplified as <code>"x^4 + x^3"</code>.</p></li>
  </ul>
  
  <p>Is there a command for this in python?</p>
  
  <p>Thanks in advance.</p>
  
  <p>/Alex</p>
  
  <p>//the code</p>
  
  <pre><code>def polynomial_to_string(p_list):
      terms = []
      degree = 0
  
      for coeff in p_list:
          if degree == 0:
              terms.append(str(coeff))
          elif degree == 1:
              terms.append(str(coeff) + 'x')
          else:
              term = str(coeff) + 'x^' + str(degree)
              terms.append(term)
          degree += 1
  
      terms.reverse()
      final_string = ' + '.join(terms)
  
      return final_string
  </code></pre>