0

so I want to run a piece of code that will run the entire time yet I also want to run the rest of my script.

example:

import time
counter = 0

#i want to run this code the entire time:

while True:
     print(counter)
     counter = counter + 1
     time.sleep(1)
     continue


#but i also want to run this code so the user can add more to the counter:

userinput = input()
if userinput == "":
    counter = counter + 10
  • You can use APScheduler. – bekirbakar Jul 21 '22 at 12:41
  • This is a kind of consumer/producer problem. You can split your script into 2 scripts , 1 to read data from user and store it somewhere (file, cache or db) and then another which read from data-store and do the needful task. – Sandeep Rawat Jul 21 '22 at 12:41

0 Answers0