Skip to content

Instantly share code, notes, and snippets.

@JackInTaiwan
Created November 21, 2018 06:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JackInTaiwan/10e098c60f884f6760ad899c52381a69 to your computer and use it in GitHub Desktop.
Save JackInTaiwan/10e098c60f884f6760ad899c52381a69 to your computer and use it in GitHub Desktop.
def dog():
height = 40
def grow_up():
nonlocal height
height = height + 1
def show_height():
print("Thanks for making me growing up. I'm now {} meters !!!!".format(height))
return show_height
return grow_up
if __name__ == "__main__":
dog_1_grow_up = dog()
dog_1_grow_up()
dog_1_grow_up()
dog_1_grow_up()()
# > Thanks for making me growing up. I'm now 43 meters !!!!
dog_2_grow_up = dog()
dog_2_grow_up()()
# > Thanks for making me growing up. I'm now 41 meters !!!!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment