I'm trying to execute a while loop only under a defined time like this, but the while loop continues its execution even when we are above the defined limit :
import datetime
import time
now = datetime.datetime.now()
minute = now.minute
while minute < 46 :
print "test"
time.sleep(5)
minute = now.minute
How can stop the loop once we cross the limit ?
Thanks
nowis defined outsidewhileand hence, will be a constant value.