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>a) your code seems fine.</p>

<pre><code>$ python
Python 2.7.10 (default, Oct 14 2015, 16:09:02) 
[GCC 5.2.1 20151010] on linux2
Type "help", "copyright", "credits" or "license" for more information.
&gt;&gt;&gt; index=""
&gt;&gt;&gt; while not index:
...     index=int(input("blabla: "))
... 
blabla: 2
&gt;&gt;&gt; print(index)
2
</code></pre>

<p>Or with python 3:</p>

<pre><code>$ python3
Python 3.4.3+ (default, Oct 14 2015, 16:03:50) 
[GCC 5.2.1 20151010] on linux
Type "help", "copyright", "credits" or "license" for more information.
&gt;&gt;&gt; index=""
&gt;&gt;&gt; while not index:
...     index=int(input("bla: "))
... 
bla: 4
&gt;&gt;&gt; print(index)
4
</code></pre>

<p>b) My console is closing: This seems to be the actual problem. Can you specify your operating system and terminal? How did you invoke the python interpreter? I guess you are on Windows? Start a console by hitting windowskey+r and type "cmd", then run python from there to see the output.</p>

python loops console