On Mon, Sep 24, 2012 at 7:57 PM, Dwight Hutto <dwightdhu...@gmail.com> wrote: > On Mon, Sep 24, 2012 at 7:43 PM, Jayden <jayden.s...@gmail.com> wrote: >> Dear All, >> >> I have a simple code as follows: >> >> # Begin >> a = 1 >> >> def f(): >> print a >> >> def g(): >> a = 20 >> f()
this prints a from calling f() function call print a wasn't in a class where it was self.a and changed, so it performed the function f which prints a and a = 1, but g just assigns the 20, and calls the f() function which shows a, there is no self.a, nor a class to show this in. >> >> g() >> #End >> >> I think the results should be 20, but it is 1. Would you please tell me why? >> >> Thanks a lot! >> >> -- >> http://mail.python.org/mailman/listinfo/python-list > > didn't return the value, or print it out > > > -- > Best Regards, > David Hutto > CEO: http://www.hitwebdevelopment.com -- Best Regards, David Hutto CEO: http://www.hitwebdevelopment.com -- http://mail.python.org/mailman/listinfo/python-list