title: While Loop With Yes/No Input (Python)
body: <p>I am building a script to plot smooth and plot values. However, I am having trouble getting the yes/no function to control the while loop.</p>
  
  <p>I am setting the while condition equal to "N" and waiting for the user to say they like the plotting (input of Y) before exiting.</p>
  
  <p>I am getting a "NameError: name 'reply' is not defined."</p>
  
  <pre><code>import matplotlib.pyplot as plt
  import numpy
  
  while True:
      reply[0] = 'n'
      def yes_or_no(question):
          reply = str(input(question+' (y/n): ')).lower().strip()
          if reply[0] == 'y':
              return 1
          if reply[0] == 'n':
              return 0
          else:
              return yes_or_no("Please Enter (y/n) ")
  
  # a bunch of math
  # plots for the user
  
  yes_or_no('Do you like the plot')
  break
  print("done")
  </code></pre>
  
  <p>When I adjusted reply[0] to reply the program hangs (see below) </p>
  
  <pre><code>print("started")
  while True:
      reply = 'n'
      def yes_or_no(question):
          reply = str(input(question+' (y/n): ')).lower().strip()
          if reply[0] == 'y':
              return 1
          if reply[0] == 'n':
              return 0
          else:
              return yes_or_no("Please Enter (y/n) ")
  
  yes_or_no('Do you like the plot')
  print("done")
  </code></pre>