Search code examples
pythonrandompyautogui

Getting int object is not iterable error


so I'm using pyautogui to type in a textbox and I'm trying to type a random integer something like this.

    import pyautogui
    import random
    pyautogui.typewrite(random.randint(0, 1000))

but I'm getting a 'int object is not iterable' error. Is there any way to fix this?


Solution

  • typewrite takes a string (or list of strings), not an integer.

    pyautogui.typewrite(str(random.randint(0, 1000)))