Pause in "for i in range" with in python

Question:

How can I make a pause in a "for i in range" loop, for example after 100 calls?

I have this part of the code:

with open(r'urlurl.txt', encoding='utf8') as f:
    for i in range(total_urls):

Now I want to make a big pause after 100 calls.

All I find is to do time.sleep() or set a random pause between calls, but this is not what I need. I already have a 10 second pause between calls, but I need to make a longer pause after 100 calls.

Asked By: Nero

||

Answers:

Like this?

with open(r'urlurl.txt', encoding='utf8') as f:
    for i in range(total_urls):
        if i > 0 and i % 100 == 0:
            time.sleep(100)
Answered By: Nikolay Zakirov
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.