code: def quote_string_if_needed(arg: str) -> str:
      
      if is_quoted(arg) or ' ' not in arg:
          return arg
  
      if '"' in arg:
          quote = "'"
      else:
          quote = '"'
  
      return quote + arg + quote
docs: Quotes a string if it contains spaces and isn't already quoted