#!/usr/bin/env python from datetime import timedelta def time_to_dict(time): return {"minutes": int(time.split(":")[0]), "seconds": int(time.split(":")[1])} length_of_period = timedelta(**time_to_dict("18:20")) start_of_period = timedelta(**time_to_dict("29:14")) shot_at_timestamp = timedelta(**time_to_dict(input("Shot at: "))) shot_at_diff = shot_at_timestamp - start_of_period shot_at_period_time = length_of_period - shot_at_diff print("{}:{}".format(str(shot_at_period_time.seconds // 60).rjust(2, "0"), str(shot_at_period_time.seconds % 60).rjust(2, "0")))