Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- hours = int(input())
- minutes = int(input())
- day_part = input()
- hours_added = int(input())
- minutes_added = int(input())
- result = (hours + hours_added) * 60 + minutes + minutes_added
- total_hours = int(result / 60 % 24)
- total_minutes = result % 60
- day_part = ("PM" if day_part == "AM" else "AM") if total_hours >= 12 else day_part
- total_hours -= 12 if total_hours > 12 else 0
- print(f"{total_hours:02}:{total_minutes:02}:{day_part}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement