title: What does error message -(AttributeError: Worm instance has no attribute 'vx') mean and how can i fix it?
body: <p>I've been following <a href="http://lorenzod8n.wordpress.com/category/pygame-tutorial/" rel="nofollow">a tutorial</a> but keep getting the following error<br>
  <code>AttributeError: Worm instance has no attribute 'move'</code><br>
  I'm not sure exactly what it means or how to fix it. The error refers to line 44 towards the bottom the line is <code>w.move()</code><strong>(this one's solved look below)</strong></p>
  
  <pre><code>import pygame
  
  class Worm:
      """A Worm."""
      def __init__(self, surface, x, y, length):
          self.surface = surface
          self.x = x
          self.y = y
          self.length = length
          self.dir_x = 0
          self.dir_y = -1
          self.body = []
          self.crashed = False
  
      def key_event(self, event):
          """Handle Key events that affect the worm."""
          if event.key == pygame.K_UP:
              self.dir_x = 0
              self.dir_y = -1
          elif event.key == pygame.K_DOWN:
              self.dir_x = 0
              self.dir_y = 1
          elif event.key == pygame.K_DOWN:
              self.dir_x = -1
              self.dir_y = 0
          elif event.key == pygame.K_DOWN:
              self.dir_x = 1
              self.dir_y = 0 
      def draw(self):
          for x, y in self.body:
              self.surface.set_at((x, y), (255, 255, 255))
  
  width = 640
  height = 400
  
  screen = pygame.display.set_mode((width, height))
  clock = pygame.time.Clock()
  running = True
  
  w = Worm(screen, width/2, height/2, 200)
  
  while running:
      screen.fill((0, 0, 0))
      w.move()
      w.draw()
  
      if w.crashed or w.x &lt;= 0 or w.x &gt;= width -1 or w.y &lt;= 0 or w.y &gt;= height -1:
          print "crash"
          running = False
  
      for event in  pygame.event.get():
          if event.type == pygame.QUIT:
              running = False
          elif event.type == pygame.KEYDOWN:
              w.key_event(event)
  
      pygame.display.flip()
      clock.tick(240)
  </code></pre>
  
  <p>----------Change --------</p>
  
  <p>code:</p>
  
  <pre><code>import pygame
  
  class Worm:
      """A Worm."""
      def __init__(self, surface, x, y, length):
          self.surface = surface
          self.x = x
          self.y = y
          self.length = length
          self.dir_x = 0
          self.dir_y = -1
          self.body = []
          self.crashed = False
  
      def key_event(self, event):
          """Handle Key events that affect the worm."""
          if event.key == pygame.K_UP:
              self.dir_x = 0
              self.dir_y = -1
          elif event.key == pygame.K_DOWN:
              self.dir_x = 0
              self.dir_y = 1
          elif event.key == pygame.K_DOWN:
              self.dir_x = -1
              self.dir_y = 0
          elif event.key == pygame.K_DOWN:
              self.dir_x = 1
              self.dir_y = 0 
      def draw(self):
          for x, y in self.body:
              self.surface.set_at((x, y), (255, 255, 255))
      def move(self):
          """move worm."""
          self.x += self.vx
          self.y += self.vy
  
          if (self.x, sel.y) in self.body:
              self.crashed = True
  
          self.body.insert(0, (self.x, self.y))
  
          if len(self.body) &gt; self.length:
              self.body.pop()
  
      def draw(self):
          #for x, y self.body:
          #    self.surface.set_at((x, y),self.color)
          x, y = self.body[0]
          self.surface.set_at((x, y), self.color)
          x, y = self.body[-1]
          self.surface.set_at((x, y), (0, 0, 0))
  
  
  width = 640
  height = 400
  
  screen = pygame.display.set_mode((width, height))
  clock = pygame.time.Clock()
  running = True
  
  w = Worm(screen, width/2, height/2, 200)
  
  while running:
      screen.fill((0, 0, 0))
      w.move()
      w.draw()
  
      if w.crashed or w.x &lt;= 0 or w.x &gt;= width -1 or w.y &lt;= 0 or w.y &gt;= height -1:
          print "crash"
          running = False
  
      for event in  pygame.event.get():
          if event.type == pygame.QUIT:
              running = False
          elif event.type == pygame.KEYDOWN:
              w.key_event(event)
  
      pygame.display.flip()
      clock.tick(240)
  </code></pre>
  
  <p>and Error - </p>
  
  <pre><code>Traceback (most recent call last):
    File "C:/Users/Enrique/Dropbox/Public/snakegametutorial.py", line 65, in &lt;module&gt;
      w.move()
    File "C:/Users/Enrique/Dropbox/Public/snakegametutorial.py", line 34, in move
      self.x += self.vx
  AttributeError: Worm instance has no attribute 'vx'
  </code></pre>