code: def string_to_time(value):
      
      try:
          return datetime.datetime.strptime(value, '%H:%M:%S').time()
      except ValueError:
          return datetime.datetime.strptime(value, '%H:%M').time()
docs: Return an instance ``datetime.time`` that corresponds to the specified
      string representation.
  
      @param value: a string representation of a time ``HH:MM[:SS]``, where:
  
          * ``HH``: hour (24-hour clock) as a zero-padded decimal number.
  
          * ``MM``: minute as a zero-padded decimal number.
  
          * ``SS``: second as a zero-padded decimal number.
  
      @return: an instance ``datetime.time`` represented by the string.
  
      @raise ValueError: if the string representation doesn't correspond to
          a valid time.