On 25/12/11 10:18, daedae11 wrote:
The following program has an error :
new += lists[int(j)]+"-";
UnboundLocalError: local variable 'new' referenced before assignment
Others have answered the question for you however there are two
additional points to make:
1) Always send the complete erroir
On Sun, Dec 25, 2011 at 6:00 AM, Lie Ryan wrote:
> On 12/25/2011 09:46 PM, Joel Goldstick wrote:
>>
>>
>> You can either move the stuff at the top of your program into main, or
>> you could pass the outer new
>> into main as a parameter: main(new):
>
>
> the third alternative is to use the glob
On 12/25/2011 09:46 PM, Joel Goldstick wrote:
You can either move the stuff at the top of your program into main, or
you could pass the outer new
into main as a parameter:main(new):
the third alternative is to use the global keyword, e.g.
# declare a global named 'new'
new = 0
def increm
On Sun, Dec 25, 2011 at 5:18 AM, daedae11 wrote:
> The following program has an error :
> new += lists[int(j)]+"-";
> UnboundLocalError: local variable 'new' referenced before assignment
>
> But when I put the sentence " new = '' " in the main() function,
The following program has an error :
new += lists[int(j)]+"-";
UnboundLocalError: local variable 'new' referenced before assignment
But when I put the sentence " new = '' " in the main() function, the program
run normally.
Please tell me why? Isn't va