In Python ArcGIS Pro 2.7, I'm trying to get the active layer in a Map TOC. I can get the CURRENT project and active map, but I've met my threshold to get the active layer in the map. I thought it might be a property of listlayers or even the active map, but not the case.
Here is a part of my code. Ultimately, I'm trying to get the active layer and pass a Definition Query to it. Below I have the layer in question (County) hardcoded, but I want to replace this with the active layer variable. After I get the lyr, then I build a Def Query using pre-defined input.
aprx = arcpy.mp.ArcGISProject("CURRENT")
currentmap = aprx.activeMap
lyr = currentmap.listLayers("County")[0]
qry = '\"%s\" = \'%s\'' %(in1,in2)
lyr.definitionQuery = qry