-
-
Save panzi/150ef9eeeca20cce2871 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def make_adder(): | |
grand_total = 0 | |
def adder(to_add): | |
nonlocal grand_total | |
print("Grand total moved from: %s" % grand_total) | |
grand_total += to_add | |
print("To: %s \n" % grand_total) | |
return grand_total | |
return adder | |
adder = make_adder() | |
adder(1) | |
adder(2) | |
adder(3) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
And now it works. So where is the problem?