John Honai
John Honai

Reputation: 69

Add a time delay in python count up function for the multiples of a given number

My function is:

import time

count = int()

while True:
  count += 1
  time.sleep(1)
  if count == 50:
    time.sleep(5)

I need to put a time delay in every multiple of 50.

Upvotes: 1

Views: 349

Answers (2)

user15801675
user15801675

Reputation:

You can do something like this

import time
for count in range(1000):
    if count %50==0:
        print ('Number divisible by 50')
        time.sleep(5)

Upvotes: 1

Nastor
Nastor

Reputation: 638

import time

count = int()

<
count += 1
do some function
>

if (count % 50) == 0:
  time.sleep(5)

This should do it.

Upvotes: 0

Related Questions