<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def TrimBeginningAndEndingSlashes(path):
 """Trims beginning and ending slashes :param str path: :return: Path with beginning and ending slashes trimmed. :rtype: str """

    if path.startswith('/'):
        # Returns substring starting from index 1 to end of the string
        path = path[1:]

    if path.endswith('/'):
        # Returns substring starting from beginning to last but one char in the string
        path = path[:-1]

    return path