/samenamelocalglobalin functiona variable will either always be global or always be local the code in function can' use local variable named eggs and then use the global eggs variable later in that same function note if you ever want to modify the value stored in global variable from in functionyou must use global statement on that variable if you try to use local variable in function before you assign value to itas in the following programpython will give you an error to see thisenter the following into the file editor and save it as samenameerror pydef spam()print(eggserroreggs 'spam localeggs 'globalspam(if you run the previous programit produces an error message traceback (most recent call last)file " :/samenameerror py"line in spam(file " :/samenameerror py"line in spam print(eggserrorunboundlocalerrorlocal variable 'eggsreferenced before assignment you can view the execution of this program at /samenameerrorthis error happens because python sees that there is an assignment statement for eggs in the spam(function andthereforeconsiders eggs to be local but because print(eggsis executed before eggs is assigned anythingthe local variable eggs doesn' exist python will not fall back to using the global eggs variable unc tions "bl ack box softenall you need to know about function are its inputs (the parametersand output valueyou don' always have to burden yourself with how the function' code actually works when you think about functions in this high-level wayit' common to say that you're treating function as "black box this idea is fundamental to modern programming later in this book will show you several modules with functions that were written by other people while you can take peek at the source code if you're curiousyou don' need to know how these functions work in order to use them and because writing functions without global variables is encouragedyou usually don' have to worry about the function' code interacting with the rest of your program