import time
import sys
def format_time(total_seconds):
hours = total_seconds // 3600
minutes = (total_seconds % 3600) // 60
seconds = total_seconds % 60
return f"{hours:02d}:{minutes:02d}:{seconds:02d}"
def phone_style_timer():
total_seconds_input = 0
while True:
try:
print("Set the time for the timer:")
hours_str = input("Hours (0-23): ")
minutes_str = input("Minutes (0-59): ")
seconds_str = input("Seconds (0-59): ")
hours = int(hours_str)
minutes = int(minutes_str)
seconds = int(seconds_str)
if not (0 <= hours <= 23 and
0 <= minutes <= 59 and
0 <= seconds <= 59):
print("Error: Please enter valid values (hours 0-23, minutes/seconds 0-59).")
continue
total_seconds_input = hours * 3600 + minutes * 60 + seconds
if total_seconds_input <= 0:
print("Error: Total time must be greater than zero.")
continue
break
except ValueError:
print("Ошибка: Введите только целые числа.")
print("\nТаймер запущен!")
while total_seconds_input >= 0:
sys.stdout.write(f"\rОсталось: {format_time(total_seconds_input)}")
sys.stdout.flush()
time.sleep(1)
total_seconds_input -= 1
print("\nВремя вышло!")
phone_style_timer()