I have a python script that should turn off all layers in a ArcGIS Pro project. But when I run it, the following error pops up:
File "<string>", line 2, in <module>
IndexError: list index out of range
Here is the python code I am using.
<SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: inherit;">p =</SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: inherit;"> arcpy</SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: inherit;">.</SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: inherit;">mp</SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: inherit;">.</SPAN><SPAN class="" style="color: #2b91af; border: 0px; font-weight: inherit; font-size: inherit;">ArcGISProject</SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: inherit;">("Current</SPAN><SPAN class="" style="color: #7d2727; border: 0px; font-weight: inherit; font-size: inherit;">"</SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: inherit;">)
</SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: inherit;">m </SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: inherit;">=</SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: inherit;"> p</SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: inherit;">.</SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: inherit;">listMaps</SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: inherit;">(</SPAN><SPAN class="" style="color: #7d2727; border: 0px; font-weight: inherit; font-size: inherit;">"Name of map"</SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: inherit;">)[</SPAN><SPAN class="" style="color: #7d2727; border: 0px; font-weight: inherit; font-size: inherit;">0</SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: inherit;">]
</SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: inherit;">lyrList </SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: inherit;">=</SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: inherit;"> m</SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: inherit;">.</SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: inherit;">listLayers</SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: inherit;">()
</SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: inherit;"></SPAN><SPAN class="" style="color: #101094; border: 0px; font-weight: inherit; font-size: inherit;">for</SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: inherit;"> lyr </SPAN><SPAN class="" style="color: #101094; border: 0px; font-weight: inherit; font-size: inherit;">in</SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: inherit;"> lyrList</SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: inherit;">:</SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: inherit;">
lyr</SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: inherit;">.</SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: inherit;">visible </SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: inherit;">=</SPAN><SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: inherit;"> </SPAN><SPAN class="" style="color: #101094; border: 0px; font-weight: inherit; font-size: inherit;">False</SPAN>Anyone know what I am doing wrong or missing?