Skip to content

Instantly share code, notes, and snippets.

@Robofied
Last active February 3, 2019 14:34
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 Robofied/260ca1911345afb7660748adf4bda489 to your computer and use it in GitHub Desktop.
Save Robofied/260ca1911345afb7660748adf4bda489 to your computer and use it in GitHub Desktop.
## Creating a global variable
a = "Hello! Welcome to python tutorials."
def func():
## It is another local variable of function func()
a = "Hello! Everyone"
print(a)
## Here it will print the value of global variable "a" which is not changed even if the a's value
## in function func() is changed because func() is not accessing the global variable and then chnaging it.
## It is actually creating another local variable.
func()
## It will print global variable value.
print(a)
#[Output]:
"Hello! Everyone"
"Hello! Welcome to python tutorials."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment