Python while loop closing console
<p>My console is closing every time I start the loop and I don't get why...</p>

<pre><code>index = ""  
while not index:
    index = int(input("Enter the index that you want: "))
</code></pre>

<p>I think your issue is that your loop is executing only once and is exiting after that (<em>that's what I can think of based on your code</em>).</p>

<p><strong>The reason is:</strong> at the start, your index is <code>""</code>. Hence <code>not index</code> is evaluated as <code>True</code> since python considers empty string as <code>False</code>. But within the loop you are assigning value to the index. Hence, in the next run <code>not index</code> is returning <code>False</code>. </p>

<p>Below is the sample on how ti works:</p>

<pre><code>&gt;&gt;&gt; index = "" 
&gt;&gt;&gt; not index
True  &lt;--- True since string is empty
&gt;&gt;&gt; index = 3
&gt;&gt;&gt; not index  
False &lt;--- False since string is having some value 
</code></pre>

python loops console