This question has already been answered:
- How to make a temporary cycle? 4 replies
Hello! I want to write an improvement for my game that will be valid for 30 seconds. For this, I used the time module and created a while loop.
import time # timeout variable can be omitted, if you use specific value in the while condition timeout = 300 # [seconds] timeout_start = time.time() while time.time() < timeout_start + timeout: test = 0 if test == 5: break test -= 1 #Пример print('example') But this does not suit me, since print ('example') will be executed only upon completion of the while loop. I decided to use such a loop, which also does not suit me because example is displayed on the screen while the while loop is running too often.
import time # timeout variable can be omitted, if you use specific value in the while condition timeout = 300 # [seconds] timeout_start = time.time() while time.time() < timeout_start + timeout: test = 0 if test == 5: break test -= 1 #Пример print('example') Please help me solve this problem. I need the game to work while I use the enhancement.