import keyboard
import time
s1 = 1
time.sleep(1)
while s1 < 100:
keyboard.write(s1)
s1 = s1 1
I can't write s1
because 1 is an int. But if I make it s1 = "1"
then I can't do s1 < 100
because s1
is a string, so I need to write s1
, but how?
CodePudding user response:
You can use the int() or str() function where you need the value to be a string or int without reassigning it.
import keyboard
import time
s1=1
time.sleep(1)
while s1<100:
keyboard.write(str(s1))
s1=s1 1
CodePudding user response:
I think this is what you're trying to do here. I also changed the last line as it's simpler like that
import keyboard
import time
s1 = 1
time.sleep(1)
while s1 < 100:
keyboard.write(str(s1))
s1 = 1