title: Invalid syntax in else: python
body: <pre><code>for lyr in QgsMapLayerRegistry.instance().mapLayers().values():
          if lyr.name() == "us_city_pop_gt_10k_albersaea":
              layer = lyr
          self.dlg.Statecombo.clear()
  
          else:
              QMessageBox.warning(self.dlg, "Layer Name","Load us_city_pop_gt_10k_albersaea layer and  try again")
  </code></pre>
  
  <p>I am giving conditionals that if a layer name exists do this, else give a warning message. But it shows an error "Invalid Syntax". Please help me in figuring out this.Thanks in advance.</p>