UnboundLocalError
<p>I want to find the index of the first element of myArray which is >= the max array value. EDIT: When I run this code:</p>

<pre><code>fitPeak = max(myArray)
fitPeakIndex = numpy.argmax(myArray)
halfMax = 0.5*fitPeak

for i in range(1,fitPeakIndex):
    fitNow = myArray[i]
    if fitNow&gt;=halfMax:
        fitLeftIndex = i
        break
    else:
        continue

for j in range(fitPeakIndex,len(myArray)):
    fitNow = myArray[j]
    if fitNow&lt;=halfMax:
        fitRightIndex = j
        break
    else:
        continue

fitFwhm = fitRightIndex - fitLeftIndex
</code></pre>

<p>I get the error</p>

<pre><code>UnboundLocalError: local variable 'leftIndex' referenced before assignment
</code></pre>

<p>Where the error occurred at the last line.
What went wrong?</p>
