<html>
  <head>

    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <font size="4">My intention was to create a new vector layer
      consisting of several polygons.  I used the CreatePolygon tool to
      mark the four vertices of a rectangle.  I must have done something
      wrong because I've ended up with a polygon that seems to belong to
      no layer.   In desperation I ran the following python code, hoping
      to delete the mysterious polygon, but it's still there.  Are some
      layers not in the legend?  How do I  get rid of the   polygon?   <br>
      ========================<br>
      from qgis.core import QgsProject<br>
      from qgis.utils import iface<br>
      <br>
      project = QgsProject.instance()<br>
      for lyr in project.mapLayers().values():         <br>
          lyrName = lyr.name()<br>
          print (lyrName)<br>
          QgsProject.instance().removeMapLayers([lyr.id()]) <br>
      <br>
          <br>
      <br>
    </font>
  </body>
</html>