Search code examples
pythoncopy-pastepyperclip

Pyperclip copy and dividing the results


I'm having some issues with my code not dividing the copied answers and instead giving me string errors.

for x in range(5):
    time.sleep(3)
    coordinates = (pyperclip.paste())
    print(coordinates/2) 

TypeError: unsupported operand type(s) for /: 'objc.pyobjc_unicode' and 'int'


Solution

  • If you used pyperclip.copy("1234") and the string was a number then you could do this

    for x in range(5):
        time.sleep(3)
        coordinates = int(pyperclip.paste())
        print(coordinates/2)