global scope and local scope your program' variables are forgotten after the program terminates the variables created while the execution is inside function call are the same the variables are created when the function is called and forgotten when the function returns rememberfunctions are kind of like miniprograms in your program when execution is inside functionyou cannot change the variables outside of the functionincluding variables inside other functions this is because these variables exist in different "scopeall variables exist in either the global scope or function call' local scope the scope outside of all functions is called the global scope the scope inside of function (for the duration of particular function callis called local scope the entire program has only one global scope variables defined in the global scope can be read outside and inside functionsbut can only be modified outside of all functions variables created in function call can only be read or modified during that function call you can read the value of global variables from the local scopebut attempting to change global variable from the local scope won' work what python actually does in that case is create local variable with the same name as the global variable you couldfor examplehave local variable named spam at the same time as having global variable named spam python will consider these to be two different variables look at this example to see what happens when you try to change global variable from inside local scope the comments explain what is going ondef bacon()we create local variable named "spaminstead of changing the value of the global variable "spam"spam the name "spamnow refers to the local variable only for the rest of this functionprint(spam spam global variable named "spam"print(spam bacon(call the bacon(functionthe global variable was not changed in bacon()print(spam when runthis code will output the following