def timeConversion(s):
hour, minute, second_AMPM = s.split(':')
if second_AMPM[2:] == "PM" and hour != '12':
hour =str(int(hour)+12)
if second_AMPM[2:] == "AM" and hour == '12':
hour = "00"
if second_AMPM[2:] == "PM" and hour == '12':
hour = "12"
conversion_time = hour + ':' + minute + ':' + second_AMPM[0:2]
return conversion_time
s.split() 사용법
hour, minute, second_AMPM = s.split(':')
s라는 문자형 변수를 ':'를 경계로 끊어서 각각의 변수(hour, minute, second_AMPM)에 저장