code: def handle_cd(self, cmd):
          
          if len(cmd) != 2:
              print("Invalid syntax: cd path", file=self.output)
              return
          path = os.path.expandvars(os.path.expanduser(cmd[1]))
          try:
              os.chdir(path)
          except OSError as ex:
              print("cd: %s\n" % ex, file=self.output)
docs: changes dir