title: How to change loop condition variable within loop in python
body: <p>I have a function-scoped boolean variable <code>bool_var</code> and I want to loop while <code>bool_var</code> is False. In the loop, I want to set <code>bool_var</code> equal to the return value of either <code>functionA()</code> or <code>functionB()</code> as so:</p>
  <pre class="lang-py prettyprint-override"><code>def func():
     bool_var = False
     while bool_var is False:
        if something:
           bool_var = functionA()
        else:
           bool_var = functionB()
  </code></pre>
  <p>However, the <code>bool_var = function()</code> parts are treated as a new variable (the IDE says <code>bool_var</code> is not used) and thus the loop condition is not properly updated each time.</p>
  <p>I have 2 questions about this: How do I fix/get around this and why does python want to initialize <code>bool_var</code> as a new local variable? I know it's a dynamically typed language but it feels like in a simple case like this it adds unnecessary (and unwanted) flexibility.</p>