Q : Python time
<p>I would like to use ·time()· to launch an event. An example would be to <code>print("test")</code> for 3 seconds. For that I did this: </p>

<pre><code>from time import time, sleep

from random import random

t = time()
n = 3

print(n, time() - t)

for i in range(100):
    sleep(0.04)
    print(time() - t)
    if time() - t &gt; n:
        print("test")
        break 
</code></pre>

<p>and it works! But in my game, in a while loop, it does not work... Why not?</p>