import datetime spot_cred = 'P'; tag_cred = 'R'; new_A = ('D') new_D = ('P','R') new_P = ('A','D','R','G') is_valid=0 index = 0 d = {'A': new_A, 'D': new_D, 'P': new_P} n = datetime.datetime.now(); if n.hour >= 12 and n.minute > 0: for item in d[spot_cred]: print d[spot_cred][item] elif tag_cred == spot_cred: print 'it works'