-3

I am new here so let me describe the concept first . I am having a function

if timenow == 10Pm : -> do something
elif timenow is 5min before 10pm than wait for the 10 pm and then execute the function
elif timenow is just after 10pm then directly execute the function
or
if timenow == 11Pm : -> do something
elif timenow is 5min before 11pm than wait for the 10 pm and then execute the function
elif timenow is just after 11pm then directly execute the function

The function should execute as above. But the problem is if i set everything up the following error are occoured:

if i set the function to be execute after 10pm then i cant impliment the function before 11pm.

Anyone having the concept ?

1 Answers1

0

If all of your "do something" action happen at the hour, you could try something like:

while True:
    if timenow == 10pm:
        do something
    elif timenow == 11pm:
        do something (else)
    elif ...:
        # you get the idea

    wait number of minutes to next hour
ATony
  • 683
  • 2
  • 12
  • No the problem is if i set the to be work after the 10 pm then the loop will finish on 10pm and it will not wait for 11pm – Akash kumar Mallick Dec 29 '21 at 16:23
  • @AkashkumarMallick But then this has nothing to do with the logic/pseudo-code that you wrote. It all depends on how you have the condition of your loop, and about which you don't say anything. If you don't write clear questions, one does not have the ability to divine what you are thinking. – ATony Dec 29 '21 at 18:19