Time Conversion

Problem Statement

Given a time in AM/PM format, convert it to military (24-hour) time.

Note: Midnight is 12:00:00AM on a 12-hour clock and 00:00:00 on a 24-hour clock. Noon is 12:00:00PM on a 12-hour clock and 12:00:00 on a 24-hour clock.

Input Format

A time in 12-hour clock format (i.e.: hh:mm:ssAM or hh:mm:ssPM), where 01≤hh≤12.

Output Format

Convert and print the given time in 24-hour format, where 00≤hh≤23.

Sample Input

07:05:45PM
Sample Output

19:05:45
Explanation

7 PM is after noon, so you need to add 12 hours to it during conversion. 12 + 7 = 19. Minutes and seconds do not change in 12-24 hour time conversions, so the answer is 19:05:45.

Copyright © 2015 HackerRank.
All Rights Reserved

#python

hh, mm, ss = raw_input().split(":")
h = int(hh)
T = ss[2:]
if T == 'PM' and h < 12:
    print str(12 + h) + ":" + mm + ":"+ss[0:2]
elif T == 'AM' and h == 12:
    print '00'+":"+mm+":"+ss[0:2]
else:
    print hh+":"+mm+":"+ss[0:2]