On Aug 20, 8:25 pm, Chris Rebert <c...@rebertia.com> wrote: > On Fri, Aug 20, 2010 at 11:09 AM, M B <zna...@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
Just put a global dept at the start of your function and it will work Rony -- http://mail.python.org/mailman/listinfo/python-list