I am getting a 'NoneType' object is not iterable TypeError in the code below. The code below is ment to use pyautogui to scroll through 10 images in the digits folder (named 0 through 9, named with the # in the image) and when ever it finds one, report the value of x along with the number it found. The dictionary is then sorted by x values to read the number found in the image.
Question: I am still learning Python and this TypeError has me stomped, how can I correct this?
#! python3
import sys
import pyautogui
# locate Power
found = dict()
for digit in range(10):
positions = pyautogui.locateOnScreen('digits/{}.png'.format(digit),
region=(888, 920, 150, 40), grayscale=True)
for x, _, _, _ in positions:
found[x] = str(digit)
cols = sorted(found)
value = ''.join(found[col] for col in cols)
print(value)
Traceback of the error:
Traceback (most recent call last):
File "C:\Users\test\python3.6\HC\power.py", line 10, in <module>
for x, _, _, _ in positions:
TypeError: 'NoneType' object is not iterable