2

I have a problem in passing a int variable in typewrite function under pyautogui library consider the example to have clear view

for k in range(13,ag19):        
    pyautogui.typewrite('f-'k)

I want k variable to be auto incremented but it giving the error message

2
  • 'f-'k is not a valid python expression. Commented Jul 23, 2018 at 10:15
  • I'm guessing that this is caused by the 'f-'k part. Did you mean to pass 'f-k'? Can you please post the exact error message and traceback? Commented Jul 25, 2018 at 18:11

1 Answer 1

3

What you probably might need to do is to convert the int to string , as typewrite takes string argument : Refer the below sample :

import pyautogui
ag19 = 19
for k in range(13,ag19):        
    pyautogui.typewrite('f-'+str(k))

And might need to add this in the beginning after import pyautogui :

pyautogui.PAUSE = 1         # set pyautogui.PAUSE to 1 for a one-second pause after each function call
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.