title: Python object of type 'float' has no len()
body: <p>this is the solution to a problem I'm working on (learning Python), but even the solution is giving me an error.</p>
  
  <p>Here's the code:</p>
  
  <pre><code>def compute_deriv(poly):
  
      """
      Computes and returns the derivative of a polynomial function. If the
      derivative is 0, returns [0.0].
  
      Example:
      &gt;&gt;&gt; poly = [-13.39, 0.0, 17.5, 3.0, 1.0]    # - 13.39 + 17.5x^2 + 3x^3 + x^4
      &gt;&gt;&gt; print compute_deriv(poly)        # 35^x + 9x^2 + 4x^3
      [0.0, 35.0, 9.0, 4.0]
  
      poly: list of numbers, length &gt; 0
      returns: list of numbers
      """
  
      poly_deriv = []
      if len(poly) &lt; 2:
          return [0.0]
      for j in xrange(1, len(poly)):
          poly_deriv.append(float(j * poly[j]))
      return poly_deriv
  </code></pre>
  
  <p>This is the solution given to me, but when I use the following code to call the function:</p>
  
  <pre><code>poly1 = (-13.39)
  print compute_deriv(poly1)
  </code></pre>
  
  <p>I get</p>
  
  <pre><code>TypeError: object of type 'float' has no len()
  </code></pre>
  
  <p>I've tried a couple different things inside the if statement (since this code only breaks when <code>len(poly)</code> is &lt; 2;</p>
  
  <p>I tried <code>poly_deriv.append(0.0)</code> and <code>return poly_deriv</code>, for example.</p>