0

I don't know if my title really encompasses what I am trying to accomplish. I have a list of email addresses and I want to only email about 50 a day. So I have made the following scripts neither are working:

email_list = ['[email protected]','[email protected]','[email protected]','[email protected]','[email protected]']
for num in range(0, 2):
    for email in email_list:
        print(email)
    time.sleep(2)

email_list = ['[email protected]','[email protected]','[email protected]','[email protected]','[email protected]']
    for email in email_list:
        for num in range(0, 2):
            print(email)
        time.sleep(2)

So what I would like to do is run the script for 50 times, then wait for a specific period of time then run the next cycle.

1 Answer 1

1

What about

email_list =['[email protected]','[email protected]','[email protected]','[email protected]','[email protected]']
send = 0
for email in email_list:
    print(email)
    send += 1
    if send % 50 == 0:
        time.sleep(2)

This will wait 2 second every 50 mails printed

Sign up to request clarification or add additional context in comments.

2 Comments

Looks like this works out of both of the answers I received. Why is it working with if send % 50 == 0?
the variable send counts how many mails were printed. send % 50 is the remainder of dividing send by 50, so it's 0 every 50 mails

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.