from time import perf_counter from time import sleep as delay flag: bool = False while True: state = round((perf_counter())%1) if(flag!=state): flag = state print(f"change to : {state}") print(state) delay(0.05)