Last active
February 3, 2019 14:34
-
-
Save Robofied/260ca1911345afb7660748adf4bda489 to your computer and use it in GitHub Desktop.
This file contains 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
## 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