code: def ensure_arg(args, arg, param=None):
    
    for idx, found_arg in enumerate(args):
      if found_arg == arg:
        if param is not None:
          args[idx + 1] = param
        return args
  
    args.append(arg)
    if param is not None:
      args.append(param)
    return args
docs: Make sure the arg is present in the list of args.
  
    If arg is not present, adds the arg and the optional param.
    If present and param != None, sets the parameter following the arg to param.
  
    :param list args: strings representing an argument list.
    :param string arg: argument to make sure is present in the list.
    :param string param: parameter to add or update after arg in the list.
    :return: possibly modified list of args.