add a string of character letters

Get the last two digits, then the first two, and join them:

def num_to_time(num):
    return f"{num // 100}:{num % 100:02}"

l = [(1210, 1229), (1935, 2000), (1536, 1608), (1043, 1120), (1817, 1922), (900, 1023), (1632, 1759)]

[(num_to_time(a), num_to_time(b)) for (a, b) in l]
# [('12:10', '12:29'), ('19:35', '20:00'), ('15:36', '16:08'), ('10:43', '11:20'), ('18:17', '19:22'), ('9:00', '10:23'), ('16:32', '17:59')]

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top