Created
December 1, 2017 12:28
-
-
Save erikaris/730b54c773b23160e6aeb218edfd0762 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
# 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