<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Numpy on ErrorVault — Developer Error Code Dictionary</title><link>https://errorvault.dev/tags/numpy/</link><description>Recent content in Numpy on ErrorVault — Developer Error Code Dictionary</description><generator>Hugo</generator><language>en-us</language><lastBuildDate>Sat, 05 Oct 2024 00:00:00 +0000</lastBuildDate><atom:link href="https://errorvault.dev/tags/numpy/feed.xml" rel="self" type="application/rss+xml"/><item><title>Fix IndexError: Index out of range error in Python lists and sequences</title><link>https://errorvault.dev/python/python-indexerror-out-of-bounds/</link><pubDate>Sat, 05 Oct 2024 00:00:00 +0000</pubDate><guid>https://errorvault.dev/python/python-indexerror-out-of-bounds/</guid><description>&lt;h2 id="1-symptoms">1. Symptoms&lt;/h2>
&lt;p>The &lt;code>IndexError: index X is out of bounds for axis Y with size Z&lt;/code> (or simply &lt;code>IndexError: list index out of range&lt;/code>) occurs when attempting to access an element in a sequence (list, tuple, string, or array) using an index outside its valid range. Valid indices for a sequence of length &lt;code>n&lt;/code> are from &lt;code>0&lt;/code> to &lt;code>n-1&lt;/code> (positive) or &lt;code>-1&lt;/code> to &lt;code>-n&lt;/code> (negative).&lt;/p>
&lt;p>Common manifestations:&lt;/p>
&lt;ul>
&lt;li>&lt;code>IndexError: list index out of range&lt;/code> – Most frequent, on lists.&lt;/li>
&lt;li>&lt;code>IndexError: tuple index out of range&lt;/code> – On immutable tuples.&lt;/li>
&lt;li>&lt;code>IndexError: string index out of range&lt;/code> – On strings.&lt;/li>
&lt;li>&lt;code>IndexError: index 5 is out of bounds for axis 0 with size 3&lt;/code> – NumPy arrays, specifying axis.&lt;/li>
&lt;/ul>
&lt;p>Stack traces point to the exact line:&lt;/p></description></item></channel></rss>