import time
def lamp(r, g, b):
on = f"\033[48;2;{r};{g};{b}m"
off = "\033[0m"
print(on + " " * 12 + off, end=" ")
text = input("How many seconds? ")
while not text.isdigit():
text = input("Digits only, please: ")
seconds = int(text)
print("Timer:", seconds, "seconds")
for remaining in range(seconds, 0, -1):
if remaining <= 5:
lamp(255, 200, 0) # yellow
else:
lamp(0, 200, 0) # green
print(remaining, "s")
time.sleep(1)
lamp(255, 0, 0) # red
print("time is up!")
the button copies all 23 lines. paste them into timer.py and read them there.