<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic IndexError: list index out of range in Data Management Questions</title>
    <link>https://community.esri.com/t5/data-management-questions/indexerror-list-index-out-of-range/m-p/283369#M16272</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm getting an IndexError saying it's out of range. But the Westerville dataframe is the first one and I'm using 0 to refer to it. After I run the program the cursor is at the end of the bolded line. What is Python trying to tell me?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'times new roman', times, serif;"&gt;mxd = arcpy.mapping.MapDocument(r"E:\EsriTraining\ArcPy\MapScripting\Exercise3\Westerville.mxd")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'times new roman', times, serif;"&gt;# return a list of all data frames in the mapping doc and assign it to df&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'times new roman', times, serif;"&gt;&lt;STRONG&gt;df = arcpy.mapping.ListDataFrames(mxd)[0]&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'times new roman', times, serif;"&gt;print df.name&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'times new roman', times, serif;"&gt;lyr = arcpy.mapping.ListLayers(mxd, " ", df)[1]&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-1 jive-image" height="384" src="https://community.esri.com/legacyfs/online/430198_pastedImage_2.png" width="789" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 24 Nov 2018 19:02:44 GMT</pubDate>
    <dc:creator>DougWolfinger2</dc:creator>
    <dc:date>2018-11-24T19:02:44Z</dc:date>
    <item>
      <title>IndexError: list index out of range</title>
      <link>https://community.esri.com/t5/data-management-questions/indexerror-list-index-out-of-range/m-p/283369#M16272</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm getting an IndexError saying it's out of range. But the Westerville dataframe is the first one and I'm using 0 to refer to it. After I run the program the cursor is at the end of the bolded line. What is Python trying to tell me?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'times new roman', times, serif;"&gt;mxd = arcpy.mapping.MapDocument(r"E:\EsriTraining\ArcPy\MapScripting\Exercise3\Westerville.mxd")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'times new roman', times, serif;"&gt;# return a list of all data frames in the mapping doc and assign it to df&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'times new roman', times, serif;"&gt;&lt;STRONG&gt;df = arcpy.mapping.ListDataFrames(mxd)[0]&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'times new roman', times, serif;"&gt;print df.name&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'times new roman', times, serif;"&gt;lyr = arcpy.mapping.ListLayers(mxd, " ", df)[1]&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-1 jive-image" height="384" src="https://community.esri.com/legacyfs/online/430198_pastedImage_2.png" width="789" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 24 Nov 2018 19:02:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/indexerror-list-index-out-of-range/m-p/283369#M16272</guid>
      <dc:creator>DougWolfinger2</dc:creator>
      <dc:date>2018-11-24T19:02:44Z</dc:date>
    </item>
    <item>
      <title>Re: IndexError: list index out of range</title>
      <link>https://community.esri.com/t5/data-management-questions/indexerror-list-index-out-of-range/m-p/283370#M16273</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You appear to be trying to listlayers that have a space as a name&lt;/P&gt;&lt;P&gt;&lt;SPAN style="display: inline !important; float: none; background-color: transparent; color: #3d3d3d; font-family: 'times new roman',times,serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;"&gt;lyr = arcpy.mapping.ListLayers(mxd, " ", df)[1]&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 24 Nov 2018 19:10:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/indexerror-list-index-out-of-range/m-p/283370#M16273</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2018-11-24T19:10:17Z</dc:date>
    </item>
    <item>
      <title>Re: IndexError: list index out of range</title>
      <link>https://community.esri.com/t5/data-management-questions/indexerror-list-index-out-of-range/m-p/1114795#M43639</link>
      <description>&lt;P&gt;An index in &lt;A href="http://net-informations.com/python/iq/default.htm" target="_self"&gt;Python&lt;/A&gt; refers to a position within an ordered list . This error basically means you are trying to access a value at a List index which is out of bounds i.e greater than the last index of the list or less than the least index in the list. So the first element is 0, second is 1, so on. So if there are n elements in a list, the last element is n-1 . If you try to access the empty or None element by pointing available index of the list, then you will get the "List index out of range " error. To solve this error, you should make sure that you're not trying to access a non-existent item in a list.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 08 Nov 2021 05:24:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/indexerror-list-index-out-of-range/m-p/1114795#M43639</guid>
      <dc:creator>paulocress</dc:creator>
      <dc:date>2021-11-08T05:24:47Z</dc:date>
    </item>
  </channel>
</rss>

