-
Python HackerRank : Time ConversionPrograming Language/Python 2020. 7. 31. 22:26반응형
문제
- '07:05:45PM' 의 형식을 '19:05:45' 형식으로 바꾸기
- input 00<hh<24
- output 00<= hh <=12
def timeConversion(s): s = str(s) if s[8:] == 'PM': if int(s[:2])+12 <= 23: h = int(s[:2])+12 elif: h = '12' else: if int(s[:2]) < 12: h = s[:2] else: h = '00' return (str(h)+s[2:8])
참고 : https://www.hackerrank.com/challenges/time-conversion/problem
반응형'Programing Language > Python' 카테고리의 다른 글
Python HackerRank : Forming a Magic Square (0) 2020.08.07 Python HackerRank : Grading Students (0) 2020.08.01 Python HackerRank : Plus Minus (0) 2020.07.31 Python HackerRank : Diagonal Difference (0) 2020.07.31 Python HackerRank : Compare the Triplets (0) 2020.07.31