title: Pytesseract loop error
body: <p>I'm trying to loop pytesseract code to convert multiple images(18) into strings and name the output in sequece. tried to rearrange and replace the loop position more errors accur.  </p>
  
  <pre><code>import cv2
  import numpy as np
  import pytesseract
  from PIL import Image
  
  src_path = "/home/pi/Desktop/"
  
  def get_string(img_path):
  
      for n in range(0,18):
  
          n=n+1
  
          img = cv2.imread(img_path)
  
          img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
  
          kernel = np.ones((1, 1), np.uint8)
          img = cv2.dilate(img, kernel, iterations=1)
          img = cv2.erode(img, kernel, iterations=1)
  
          cv2.imwrite(src_path + "removed_noise"+ n +".png",img)
          cv2.imwrite(src_path +"thres"+ n +".png", img)
  
          result = pytesseract.image_to_string(Image.open(src_path + "thres"+ n +".png"))
  
      return result
  
  print (get_string(src_path +"sample"+ str(n) +".jpeg"))
  print ("------ Done -------")
  </code></pre>
  
  <p>it returns an error</p>
  
  <pre><code>Traceback (most recent call last):
    File "/home/pi/Desktop/imagetostring.py", line 29, in &lt;module&gt;
      print (get_string(src_path +"sample"+ str(n) +".jpeg"))
  NameError: name 'n' is not defined
  </code></pre>