CodingTest

[파이썬 코딩 도장] 35.6 심사문제: 시간 클래스 만들기

nineDeveloper 2020. 12. 17.
728x90

정답

    @staticmethod
    def is_time_valid(time_string):
      hour, minute, second = map(int, time_string.split(':'))
      return hour <= 24 and minute <= 59 and second <= 60

    @classmethod
    def from_string(cls, time_string):
      hour, minute, second = map(int, time_string.split(':'))
      return cls(hour, minute, second)
728x90

댓글

💲 추천 글