parameters: (string, substr)
return_statement: return string[:-len(substr)]
docstring: Removes substr at the end of string, and raises ValueError on failure.
  
      >>> rstrip_once("test.cpp", ".cpp")
      'test'
docstring_summary: Removes substr at the end of string, and raises ValueError on failure.
docstring_tokens: Removes substr at the end of string and raises ValueError on failure .
function: def rstrip_once(string, substr):
      """
      Removes substr at the end of string, and raises ValueError on failure.
  
      >>> rstrip_once("test.cpp", ".cpp")
      'test'
      """
      if not string.endswith(substr):
          raise ValueError(
              f"{repr(string)} doesn't end with {repr(substr)}")
  
      return string[:-len(substr)]
function_tokens: def rstrip_once ( string , substr ) : if not string . endswith ( substr ) : raise ValueError ( f"{repr(string)} doesn't end with {repr(substr)}" ) return string [ : - len ( substr ) ]