technicallyit' perfectly acceptable to use the same variable name for global variable and local variables in different scopes in python butto simplify your lifeavoid doing this to see what happensenter the following code into the file editor and save it as localglobalsamename pydef spam()eggs 'spam localprint(eggsprints 'spam localdef bacon()eggs 'bacon localprint(eggsprints 'bacon localspam(print(eggsprints 'bacon localeggs 'globalbacon(print(eggsprints 'globalwhen you run this programit outputs the followingbacon local spam local bacon local global you can view the execution of this program at /localglobalsamenamethere are actually three different variables in this programbut confusingly they are all named eggs the variables are as followsu variable named eggs that exists in local scope when spam(is called variable named eggs that exists in local scope when bacon(is called variable named eggs that exists in the global scope since these three separate variables all have the same nameit can be confusing to keep track of which one is being used at any given time this is why you should avoid using the same variable name in different scopes the global statement if you need to modify global variable from within functionuse the global statement if you have line such as global eggs at the top of functionit tells python"in this functioneggs refers to the global variableso don' create local variable with this name for exampleenter the following code into the file editor and save it as globalstatement pydef spam()global eggs eggs 'spam