scope of variable
Chris Rebert
clp2 at rebertia.com
Fri Aug 20 14:25:05 EDT 2010
On Fri, Aug 20, 2010 at 11:09 AM, M B <znarus at telia.com> wrote:
> Hi,
> I try to learn python.
> I don't understand this:
<snip>
>>>> dept=0
<snip>
>>>> def mud():
> dept+=1
> print dept
>
>>>> mud()
> Traceback (most recent call last):
> File "<pyshell#7>", line 1, in <module>
> mud()
> File "<pyshell#6>", line 2, in mud
> dept+=1
> UnboundLocalError: local variable 'dept' referenced before assignment
http://www.mail-archive.com/python-list@python.org/msg75263.html
Cheers,
Chris
--
Google is your friend
http://blog.rebertia.com
More information about the Python-list
mailing list