Skip to content

Instantly share code, notes, and snippets.

@erikaris
Created December 1, 2017 12:28
Show Gist options
  • Save erikaris/730b54c773b23160e6aeb218edfd0762 to your computer and use it in GitHub Desktop.
Save erikaris/730b54c773b23160e6aeb218edfd0762 to your computer and use it in GitHub Desktop.
# This function has a global variable
# and local variable with the same name 's'
# there's a variable assignment inside the function f
# thus, it only recognizes the local variable
# which is: s = "Mukhlisina"
def f():
s = "Mukhlisina"
print(s)
# Global scope
s = "Erika Siregar"
f()
print(s) # s here is the global s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment