title: how to make something repeat x amount of times every n seconds in python?
body: <p>Let's say, i want a beeping sound be heard a total of 5 times, with 5 second break with each beep. For that, i tried using threading module, and made this:</p>
  <pre><code>import threading
  import winsound
  i = 0
  def beep():
     global i
     while i &lt; 5:
           i += 1
           threading.Timer(5.0, beep).start()
           winsound.PlaySound(&quot;beep&quot;, winsound.SND_FILENAME)
  
  beep()
  </code></pre>
  <p>This code repeats it succesfully i amount of times, but ignores a time interval and instead does it on a much faster, equally distributed unchangeable interval. I know that happens because of how while loop works, but I cant seem to find any alternative. Every piece of information would come in handy!</p>