title: Calling variables defined within "Check for Type" script
body: <p>I am checking to see if a string a user has entered can be converted into a float. I want to construct this like a loop, where the user is prompted to enter a valid value, and the loop is broken if the value is successfully converted into a float. I also want to use this new, converted value elsewhere in my script for calculations later on.</p>
  
  <pre><code>dist_string = raw_input("Enter a distance in meters to use as a buffer: ")
  try:
      dist = float(dist_string)
      print dist
  except ValueError:
      #Prompt user to enter a number if they entered a string
      dist_string = raw_input("Please enter an integer or float value: ")
  
  print(dist)
  </code></pre>
  
  <p>The following error is raised when I try to call 'dist' outside of the function (I need to use this converted float value elsewhere):</p>
  
  <pre><code>Traceback (most recent call last):
    File "F:\407_Lab05\Script1.py", line 194, in &lt;module&gt;
      print(dist)
  NameError: name 'dist' is not defined
  
  </code></pre>
  
  <p>Any ideas?</p>