[enter image description here][1]So the problem is i want to add 2 given input times, say for example - time1 = 19 50 (i want to add the time in this specific format) time2 = 02 20
i have this one code but it only works for certain time inputs,
x=[int(e) for e in input().split()]
y=[int(e) for e in input().split()]
hrs=x[0]+y[0]
min=x[1]+y[1]
if min>=60:
min=min-60
hrs=hrs+1
if hrs>=24:
hrs=hrs-24
print(hrs,min)
what do you think the solution can be.
update: Display number with leading zeros
After some intense Thonnying, (Thonny) I got the result to be printed with 01 in hrs using the zfill() functions. here is the updated code.
x=[int(e) for e in input().split()]
y=[int(e) for e in input().split()]
hrs=x[0]+y[0]
min=x[1]+y[1]
if min>=60:
min -= 60
hrs += 1
if hrs>=24:
hrs -= 24
print(f"{str(hrs).zfill(2)} {min}")
But unfortunately, the test cases are not getting passed in tech gig code gladiator codeathon. Thanks for the help guys, noobie here is happy.