I am trying to take a string and convert into 24 hour time. For example, if I am given the string "07:05:45PM", it should return "19:05:45". I have completed all the necessary conversions, I am just not sure how I am supposed to put them all together and have it so that if there were only 5 minutes or 5 seconds, it would place a zero like "xx:05:06".
def timeConversion(s):
nums = s[:8]
hh,mm,ss = [v for v in nums.split(":")]
time = s[8:]
if time == 'AM':
return nums
else:
total = (int(hh) * 3600 + int(mm) * 60 + int(ss)) + 43200
if s == "12:00:00PM":
return nums
hh = total // 3600
mm = total // 60 % 60
ss = total % 60
print(timeConversion("07:05:45PM"))