title: Solving the VIBRATNIG STRING simulation oproblem in VPYTHON/ python
body: <p>I am a true beginner in python and right now I am stuck with the code below, I can't figured our how to move forward with it. It doesb't show me a curve which I am trying to code. The idea is that it will show two balls (which are working) and string between them, which will be moving like vibrating string of gituar in slow motion.</p>
  <p>Please give me some advices</p>
  <pre><code>from vpython import *
  import math
  
  rho = 0.01
  ten = 40.
  c = math.sqrt(ten / rho)  # 4000
  c1 = c
  ratio = c * c / (c1 * c1)
  steps = 101
  x = list(range(0, 100))
  y = list(range(0, 100))
  
  g = canvas(width=600, height=400, title=&quot;Vibrating string&quot;)
  string = curve(x, y, color=color.yellow, radius=0.5, x0=steps * [0.], x1=steps * [0.], x2=steps * [0.])
  ball1 = sphere(pos=vector(50, 0, 0), radius=2.0, color=color.red)
  ball2 = sphere(pos=vector(-50, 0, 0), radius=2.0, color=color.red)
  
  for i in range(0, 81):
      string.x0[i] = 0.00125 * i
  for i in range(81, steps):
      string.x0[i] = 0.1 - 0.005 * (i - 80)
  for i in range(0, 100):
      string.x[i] = 2.0 * i - 100.0
      string.y[i] = 300.0 * string.x0[i]
      string.pos = vector(string.x[i], string.y[i], 0)
  
  for i in range(1, 100):
      string.x1[i] = string.x0[i] + 0.5 * ratio * (string.x0[i + 1] + string.x0[i + 1] - 2 * string.x0[i])
      string.x0[i] = string.x1[i]
  
  while 1:
      rate(50)
  
      for i in range(1, 100):
          string.x2[i] = 2. * string.x1[i] - string.x0[i] + ratio * (
                  string.x1[i + 1] + string.x1[i - 1] - 2 * string.x1[i])
          string.modify(i, y=string.x1[i])
  
      for i in range(0, 100):
          string.x[i] = 2.0 * i - 100.0
          string.y[i] = 300.0 * string.x2[i]
          string.pos = vector(string.x[i], string.y[i], 0)
  
      for i in range(0, 101):
          string.x0[i] = string.x1[i]
          string.x1[i] = string.x2[i]
  </code></pre>