title: NameError in Python, name is not defined
body: <p>I'm trying to create a script, such when debugmode = 1 you can break the script by pressing the "UP" key on the LCD.  On the other hand, when debugmode = 0 it goes back to the main menu.  However, I'm getting this error:</p>
  
  <pre><code>NameError: name 'debugmode' is not defined
  </code></pre>
  
  <p>This is where debugmode is set:</p>
  
  <pre><code>if lcd.buttonPressed(lcd.LEFT):
      lcd.clear()
      lcd.message('Debug mode is enabled.')
      sleep(3)
      lcd.clear
      debugmode = 1
  elif lcd.buttonPressed(lcd.RIGHT):
      lcd.clear()
      lcd.message('Debug mode is disabled.')
      sleep(3)
      lcd.clear
      debugmode = 0
  </code></pre>
  
  <p>And this is where debugmode is called:</p>
  
  <pre><code>if debugmode == 1:
      break
  else:
      subprocess.Popen("/home/fakepath/mainmenu.py")
      break
  </code></pre>
  
  <p><strong>UPDATE</strong>: Ignacio's reply fixed my name error and kindall's comment fixed my problem with the variable not being set.  Thanks Ignacio and kindall!</p>