def alarm(seconds): time.sleep(seconds) while msvcrt.kbhit(): msvcrt.getch() while not msvcrt.kbhit(): winsound.Beep(440, 250) time.sleep(0.25)