[Tutor] An unknown error in my program

2011-12-25 Thread daedae11
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

Re: [Tutor] An unknown error in my program

2011-12-25 Thread Joel Goldstick
On Sun, Dec 25, 2011 at 5:18 AM, daedae11 daeda...@126.com 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()

Re: [Tutor] An unknown error in my program

2011-12-25 Thread Lie Ryan
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

Re: [Tutor] An unknown error in my program

2011-12-25 Thread Joel Goldstick
On Sun, Dec 25, 2011 at 6:00 AM, Lie Ryan lie.1...@gmail.com 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

Re: [Tutor] An unknown error in my program

2011-12-25 Thread Alan Gauld
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