Hi, I'm making the transition from ArcMap to ArcGIS Pro so please forgive my ignorance...
At the start of my Arcpy script, I am trying to delete all of my layers in my layout except 'Coast'. When I run my script below it crashes ArcGIS Pro. Any advice graciously accepted.
aprx <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>mp<SPAN class="punctuation token">.</SPAN>ArcGISProject<SPAN class="punctuation token">(</SPAN><SPAN class="string token">"CURRENT"</SPAN><SPAN class="punctuation token">)</SPAN>
mp <SPAN class="operator token">=</SPAN> aprx<SPAN class="punctuation token">.</SPAN>listMaps<SPAN class="punctuation token">(</SPAN><SPAN class="string token">"Map"</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">]</SPAN>
<SPAN class="comment token"># Remove all layers except coast</SPAN>
keeplyr <SPAN class="operator token">=</SPAN> mp<SPAN class="punctuation token">.</SPAN>listLayers<SPAN class="punctuation token">(</SPAN><SPAN class="string token">"Coast"</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">for</SPAN> rmlyr <SPAN class="keyword token">in</SPAN> mp<SPAN class="punctuation token">.</SPAN>listLayers<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">:</SPAN>
<SPAN class="keyword token">if</SPAN> rmlyr <SPAN class="operator token">!=</SPAN> keeplyr<SPAN class="punctuation token">:</SPAN>
mp<SPAN class="punctuation token">.</SPAN>removeLayer<SPAN class="punctuation token">(</SPAN>rmlyr<SPAN class="punctuation token">)</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>