title: Error message generated by python code from book
body: <p>I'm learning python and have been working thru some examples in a book. I've run many codes and they have run fine but I'm having trouble with one. I'm using python 3.6 on an iMac with High Sierra. My short code is here:</p>
  
  <pre><code>from vpython import *
  
  dx=0.04; dx2=dx*dx; k0=5.5*pi; dt=dx2/20.0; xmax=6.0
  xs = arange(-xmax,xmax+dx/2, dx)
  
  g=graph(width=500,height=250,title="wave packet")
  PlotObj=curve(x=xs, color=color.yellow, radius=0.1)
  g.center = (0,2,0)
  
  psr = exp(-0.5*(xs/0.5)**2) * cos(k0*xs)
  psi = exp(-0.5*(xs/0.5)**2) * sin(k0*xs)
  v = 15.0*xs**2
  
  while True:
      rate(500)
      psr[1:-1]= psr[1:-1]-(dt/dx2)*(psi[2:]+psi[:-2]-2*psi[1:-1])+dt*v[1:-1]*psi[1:-1]
      psi[1:-1]= psi[1:-1]-(dt/dx2)*(psr[2:]+psr[:-2]-2*psr[1:-1])+dt*v[1:-1]*psr[1:-1]
      PlotObj.y = 4*(psr**2 + psi**2)
  </code></pre>
  
  <p>The error message generated is below:</p>
  
  <pre><code>    Traceback (most recent call last):
    File "harmosanimate.py", line 10, in &lt;module&gt;
      psr = exp(-0.5*(xs/0.5)**2) * cos(k0*xs)
  TypeError: only length-1 arrays can be converted to Python scalars
  </code></pre>
  
  <p>Does anyone know what's wrong?</p>