code: def cut_range(string):
      
      value_range = string.split(':')
      if len(value_range) == 1:
          start = int(value_range[0])
          stop = start
      elif len(value_range) == 2:
          start, stop = tuple(int(i) if i else None for i in value_range)
      else:
          msg = "{0} is not a valid, 1-indexed range.".format(string)
          raise argparse.ArgumentTypeError(msg)
  
      if start == 0 or (stop or sys.maxsize) < (start or 0):
          msg = "{0} is not a valid, 1-indexed range.".format(string)
          raise argparse.ArgumentTypeError(msg)
  
      # Convert from 1-indexed to 0-indexed
      if start is not None and start > 0:
          start -= 1
  
      return slice(start, stop)
docs: A custom argparse 'type' to deal with sequences ranges such as 5:500.
  
      Returns a 0-based slice corresponding to the selection defined by the slice