Python Error: list index out of range <p>I keep getting the error list index out of range. I'm not sure what I'm doing wrong.</p> <p>My code:</p> <pre><code>from scanner import * def small(array): smallest=array[0] for i in range(len(array)): if (array[i]&lt;smallest): smallest=array[i] return smallest def main(): s=Scanner("data.txt") array=[] i=s.readint() while i!="": array.append(i) i=s.readint() s.close() print("The smallest is", small(array)) main() </code></pre> <p>The traceback I get:</p> <pre><code>Traceback (most recent call last): File "file.py", line 21, in &lt;module&gt; main() File "file.py", line 20, in main print("The smallest is", small(array)) File "file.py", line 5, in small smallest=array[0] IndexError: list index out of range </code></pre>