Assigning value in a while comparison expression
<p>Hi I was wondering if it was possible to assign a value in the while comparison section of the code.</p>

<p>Here is an example of the code currently</p>

<pre><code>startIndex = find(target, key, startIndex)
while( startIndex != -1):
    matchesFound += 1
    startIndex = find(target, key, startIndex + 1)
return matchesFound
</code></pre>

<p>What I want to do is move the startIndex = find(target, key, startIndex) into the while comparison expresion so it would look something like this </p>

<pre><code>while( (startIndex = find(target, key, startIndex)) != -1):
    matchesFound += 1
    startIndex + 1
return matchesFound
</code></pre>

<p>if not, what would a better refactor be?</p>

<p>Thanks </p>

<p><strong>edit</strong> 
I'm working through the MIT Open courseware 6.00 before I try out the famous 6.001 module</p>
