title: Python AttributeError: 'list' object has no attribute 'convert'
body: <p>I got some code from the answer to this question by Paul <a href="https://stackoverflow.com/questions/7116113/normalize-histogram-brightness-and-contrast-of-a-set-of-images-using-python-im">here</a>
  I am trying to learn about the code, but I got the following error when trying to run it. I had google around and found no solution to it. Anyone know how I should I write around it? Sorry I am still very new to programming</p>
  
  <pre><code>RESTART:
  C:/Users/310293649/AppData/Local/Programs/Python/Python36/equalize.py  Traceback (most recent call last):   File "C:/Users/310293649/AppData/Local/Programs/Python/Python36/equalize.py", line 24, in &lt;module&gt;
              lut = equalize(im.histogram())   
  File "C:/Users/310293649/AppData/Local/Programs/Python/Python36/equalize.py", line 6, in equalize
              h = im.convert("L").histogram() 
  AttributeError: 'list' object has no attribute 'convert'
  </code></pre>
  
  <p>Here is the code.</p>
  
  <pre><code>import operator
  from PIL import Image
  from functools import reduce
  
  def equalize(im):
      h = im.convert("L").histogram()
      lut = []
      for b in range(0, len(h), 256):
          # step size
          step = reduce(operator.add, h[b:b+256]) / 255
          # create equalization lookup table
          n = 0
          for i in range(256):
              lut.append(n / step)
              n = n + h[i+b]
      # map image through lookup table
      return im.point(lut*3)
  
  if __name__ == "__main__":
  
      im = Image.open(r'R:\Temp\AlignedPhoto_in_PNG\Aligned_IMG_1789.png')
  
      # calculate lookup table
      lut = equalize(im.histogram())
  
      # map image through lookup table
      im = im.point(lut)
      im.show()
  </code></pre>