title: correct way to iterate through only a certain part of an array?
body: <pre><code>Traceback (most recent call last):
   File "C:/Users/yaahy/PycharmProjects/Testing/testing1.py", line 45, in 
  &lt;module&gt;
      clicktheshit()
    File "C:/Users/yaahy/PycharmProjects/Testing/testing1.py", line 41, in 
  clicktheshit
      pyautogui.click(chords[0], chords[1])
  TypeError: 'NoneType' object is not subscriptable
  </code></pre>
  
  <p>since my script runs slow searching through every pixel, I want to speed it up by cutting out some of the useless pixels it looks over (the ones not in the gameregion) but using </p>
  
  <pre><code>pxlss = pxls[60:400] 
  </code></pre>
  
  <p>doesn't work, I don't know the problem because it works without attempting to cut out useless stuff, it's just slow</p>
  
  <pre><code>import pyautogui
  import time
  from PIL import Image
  import mss
  import mss.tools
  import cv2
  import numpy as np
  from PIL import ImageGrab
  import colorsys
  
  time.sleep(2)
  
  def shootfunc(xc, yc):
      pyautogui.click(xc, yc)
  
  gameregion = [71, 378, 328, 530]
  
  def findpixels(pxls):
      pxlss = pxls[60:400]
      for row, pxl in enumerate(pxlss):
          for col, pxll in enumerate(pxl):
              if col &gt;= 536 and col &lt;= 808 and row &lt;= 515 and row &gt;= 371 and pxll == (102, 102, 102):
                  foundpxl = pxll
                  print(str(col) + " , " + str(row))
                  return [col, row]
                  break
  
  
  def clicktheshit():
      with mss.mss() as sct:
          region = {'top': 0, 'left': 0, 'width': 1920, 'height': 1080}
          imgg = sct.grab(region)
          pxls = imgg.pixels
          chords = findpixels(pxls)
          pyautogui.click(chords[0], chords[1])
  
  xx = 0
  while xx &lt;= 3000:
          clicktheshit()
          xx = xx + 1
          time.sleep(.01)
          clicktheshit()
  </code></pre>