title: Python, metric conversion program, no dictionary
body: <p>I made a code which converts one measurement to another.
  (I'm not allowed to use dictionary)
  I keep getting an error message: NameError: name 'num2' is not defined, which means the if statement in the second loop never became true I guess. Still, I have no idea what went wrong.</p>
  
  <p>Any ideas will be appreciated. Thanks!</p>
  
  <pre><code># Metric conversion program
  
  def displayWelcome():
      print('This program converts convert one length unit into another unit')
      print('Following are the available units: (mm), (cm), (m), (km), (inches), (ft), (yds), (miles)')
  
  def getConvertfrom():
      which1 = input('Which unit would you like to convert from: ')
  
  def getConvertto():    
      which2 = input ('Which unit would you like to convert to: ')
  
  
  num1 = float(input('Enter a value: '))
  
  available_units = ('mm', 'cm', 'm', 'km', 'inches', 'ft', 'yds', 'miles')
  conversions = (1, 10, 1000, 1e6, 25.4, 304.8, 914.4, 1.609344e6)
  
  # Display program welcome
  displayWelcome()
  
  # Get which conversion
  which1 = getConvertfrom()
  which2 = getConvertto()
  
  
  
  index = 0
  for i in range (0, len(available_units)):
      if available_units[i] == str(which1):
          num_in_mm = num1 * conversions[i]
  
  for j in range (0, len(available_units)):
      if available_units[j] == str(which2):
          num2 = num_in_mm / conversions[j]
  
  print(num1, which1, "is equal to", num2, which2)
  </code></pre>