code: def delete_module(modname):
      
      try:
          _ = sys.modules[modname]
      except KeyError:
          raise ValueError("Module not found in sys.modules: '{}'".format(modname))
  
      for module in list(sys.modules.keys()):
          if module and module.startswith(modname):
              del sys.modules[module]
docs: Delete module and sub-modules from `sys.module`