'str' object has no attribute 'len'
<p>Ive got a method that use to work by checking the first three letters/numbers and making sure they are the same before it continues like so </p>

<pre><code>def combineProcess(request):
    carID1 = request.POST['carID1']
    carID2 = request.POST['carID2']
    for x in range (0,3):
        a += carID1.length(x)
        b += carID2.length(x)
    if a.equals(b):
        //do something
</code></pre>

<p>before it use to work now it stopped and i get this error.</p>

<pre><code>Exception Type: UnboundLocalError
Exception Value:    

local variable 'a' referenced before assignment
</code></pre>

<p>which i never use to get a few weeks ago didnt change anything so i made a and b global.</p>

<pre><code>def combineProcess(request):
    carID1 = request.POST['carID1']
    carID2 = request.POST['carID2']
    global a,b
    for x in range (0,3):
        a += carID1.length(x)
        b += carID2.length(x)
    if a.equals(b):
        //do something
</code></pre>

<p>Now I am getting this error.</p>

<pre><code>Exception Type: NameError
Exception Value:    

name 'a' is not defined
</code></pre>

<p>Then i removed the global line and just put this</p>

<pre><code>a = "P"
</code></pre>

<p>and got the following error</p>

<pre><code>str object has no attribute length() or len()
</code></pre>

<p>which now has me puzzled how has this code stop working and why cant it recognize that a string object has a len() method. mainly I am lost how my code went from working to not working over a two weeks off.</p>