code_practice

Hackerrank 레벨업 하기9 [Time Conversion]

  • By Khel Kim, 김현호
  • 18 Jan 2019
  • Tags : coding_practice

Hackerrank 레벨업하기
문제
Time Conversion

def timeConversion(s):
    AM_PM  = s[-2:]
    TIME0 = s[:-2]
    time  = TIME0.split(':')
    if AM_PM == 'AM':
        if time[0] == '12':
            time[0] = '00'
        return  ':'.join(time)
    else:
        if time[0] !='12':
            time[0] = str(int(time[0])+12)
        return ':'.join(time)

궁금하신게 있다면 메일 주세요.
k2h7913@daum.net
cafehero123@gmail.com