title: NameError: name is not defined, even when I define the name
body: <p>I'm writing a program that parses through a text matching a pattern to the text using the BoyerMoore algorithm. I managed to get the code to find all matches, and print out the position of the matches.</p>
  
  <p>Now I also tried to get the length of the match_table and the number of comparisons. I'm quite unfamiliar with python, and the program tells me "NameError: name 'comparison' is not defined, even though it is used in the def boyer_moore.
  The program apparently doesn't save the variables for later use. I'm sorry if this sounds confusing, I'm quite new to python. The text that is being matched to can be <a href="http://combio.abo.fi/www_includes/text_course/input1.txt" rel="nofollow noreferrer">found here</a></p>
  
  <pre><code>def make_bad_match_table(pattern):
  
  length = len(pattern)
  table = {}
  for i, c in enumerate(pattern):
      if i == length-1 and not c in table:
          table[c] = length
      else:
          table[c] = length - i - 1
  
  return table
  
  
  
  
  def boyer_moore(pattern, text):
      comparison = 0
      match_table = []
      pattern_length = len(pattern)
      text_length = len(text)
      if pattern_length &gt; text_length:
          return match_table
  
      table = make_bad_match_table(pattern)
      index = pattern_length - 1
      pattern_index = pattern_length - 1
  
      while index &lt; text_length:
          if pattern[pattern_index] == text[index]:
              if pattern_index == 0:
                  match_table.append(index)
                  pattern_index = pattern_length - 1
                  index += (pattern_length * 2 - 1)
                  comparison +=1
              else:
                  pattern_index -= 1
                  index -= 1
          else:
              index += table.get(text[index], pattern_length)
              pattern_index = pattern_length - 1
  
      return match_table
      return comparison
  
  if __name__ == '__main__':
  
      file = open("CNN.txt", "r")
      target = file.read()
      pattern = "NASA"
      print(pattern,boyer_moore(pattern, target))
      print(len(match_table))
      print(comparison)
  </code></pre>