[for in range( ) append(iupon calling func()the empty list is created elements are appendedthen is destroyed when the function exits suppose instead we had declared [def func()for in range( ) append(iassigning global variables within function is possiblebut those variables must be declared as global using the global keywordin [ ] none in [ ]def bind_a_variable()global [bind_a_variable(in [ ]print [ generally discourage people from using the global keyword frequently typically global variables are used to store some kind of state in system if you find yourself using lot of themit' probably sign that some object-oriented programming (using classesis in order functions can be declared anywhereand there is no problem with having local functions that are dynamically created when function is calleddef outer_function(xyz)def inner_function(abc)pass pass in the above codethe inner_function will not exist until outer_function is called as soon as outer_function is done executingthe inner_function is destroyed nested inner functions can access the local namespace of the enclosing functionbut they cannot bind new variables in it 'll talk bit more about this in the section on closures in strict senseall functions are local to some scopethat scope may just be the module level scope functions www it-ebooks info